package com.ruoyi.drinkwater.service.impl;

import com.ruoyi.base.mapper.PublicToolsMapper;
import com.ruoyi.common.utils.BankerSRoundingUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.js.ItemCodeOverData;
import com.ruoyi.common.utils.js.Standard;
import com.ruoyi.common.utils.js.WaterLevelCompute;
import com.ruoyi.drinkwater.domain.ManualParamVo;
import com.ruoyi.drinkwater.mapper.ManualStatisticsMapper;
import com.ruoyi.drinkwater.service.ManualStatisticsService;
import com.ruoyi.utli.DrinksourceFormula;
import com.ruoyi.utli.SegmentFormula;
import com.ruoyi.utli.mapper.SegmentUtliMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class ManualStatisticsServiceImpl implements ManualStatisticsService {
    @Autowired
    private ManualStatisticsMapper manualStatisticsMapper;

    @Autowired
    private DrinksourceFormula drinksourceFormula;
    @Autowired
    private SegmentUtliMapper segmentUtliMapper;

    @Autowired
    private SegmentFormula segmentFormula;
    @Autowired
    private PublicToolsMapper publicToolsMapper;

    @Override
    public Map<String, Object> getManualTendency(ManualParamVo vo) {
        Map<String, Object> retMap = new HashMap<>();
        //计算两个日期中间的月份
        List<String> monthList = DateUtils.getMonthBetweenDate(vo.getBeginTime(), vo.getEndTime());

        if (StringUtils.isNotEmpty(vo.getBeginTime()) && StringUtils.isNotEmpty(vo.getEndTime())) {
            vo.setBeginTime(vo.getBeginTime() + "-01");
            vo.setEndTime(DateUtils.getLastDayOfMonth(DateUtils.dateTime("yyyy-MM", vo.getEndTime())));
        }
        List<String> itemCodeList = new ArrayList<>();
        if (StringUtils.isNotEmpty(vo.getItemCode())) {
            itemCodeList = Arrays.asList(vo.getItemCode().split(","));
            vo.setItemCodeList(itemCodeList);
        }
        //获取因子信息
        DecimalFormat df = new DecimalFormat("#####.####");
        List<Map<String, Object>> itemList = manualStatisticsMapper.getDrinkItemDatas(vo);
        Map<String, List<Map<String, Object>>> itemListColl = itemList.stream().collect(Collectors.groupingBy(s -> String.valueOf(s.get("id"))));
        List<Map<String, Object>> list = manualStatisticsMapper.getManualTendency(vo);
        List<Map<String, Object>> retList = new ArrayList<>();
        for (String month : monthList) {
            Map<String, Object> map = new HashMap<>();
            List<Map<String, Object>> monthTimeDatas = list.stream().filter(s -> String.valueOf(s.get("sampleDate")).equals(month)).collect(Collectors.toList());
            Map<String, List<Map<String, Object>>> monthTimeDatasColl = new HashMap<>();
            if (StringUtils.isNotEmpty(monthTimeDatas) && monthTimeDatas.size() > 0) {
                monthTimeDatasColl = monthTimeDatas.stream().collect(Collectors.groupingBy(s -> String.valueOf(s.get("itemCode"))));
            }
            for (String itemCode : itemCodeList) {
                List<Map<String, Object>> itemDatas = monthTimeDatasColl.get(itemCode);
                String value = null;
                if (StringUtils.isNotEmpty(itemDatas) && itemDatas.size() > 0) {
                    value = df.format(itemDatas.get(0).get("effectiveValue"));
                }
                map.put(itemCode + "_value", value);
            }

            map.put("month", month);
            retList.add(map);
        }
        List<Map<String, Object>> itemDataList = new ArrayList<>();
        for (String itemCode : itemCodeList) {
            Map<String, Object> map = new HashMap<>();
            List<Map<String, Object>> itemDatas = itemListColl.get(itemCode);
            Object itemName = null;
            Object unit = null;
            if (StringUtils.isNotEmpty(itemDatas) && itemDatas.size() > 0) {
                itemName = itemDatas.get(0).get("cnname");
                unit = itemDatas.get(0).get("unit");
            }
            map.put("itemCode", itemCode);
            map.put("itemName", itemName);
            map.put("unit", unit);
            itemDataList.add(map);
        }
        retMap.put("retList", retList);
        retMap.put("itemList", itemDataList);
        return retMap;
    }

    @Override
    public List<Map<String, Object>> summaryEnvironmentalDrinkSource(Map<String, Object> map) {
        List<Map<String, Object>> list = new ArrayList<>();
        // 创建一个DecimalFormat对象，指定格式为两位小数
        DecimalFormat df = new DecimalFormat("0.00");
        //处理数据id
        //默认根据区划查询
        map.put("dataTypeid", "3");
        Object drinkSourceName = map.get("drinkSourceName");
        Object drinkSourceTyep = map.get("drinksourceType");
        Object dataTypeid = map.get("dataTypeid");
        Object mgryear = map.get("mgryear");
        Object region = map.get("region");
        Object sydLevels = map.get("sydLevels");
        //如果年份为空默认查询最新的年份数据
        if (mgryear != null && !"".equals(mgryear)) {

        } else {
            Calendar calendar = Calendar.getInstance();
            int currentYear = calendar.get(Calendar.YEAR);
            int lastYear = currentYear - 1;
            mgryear = String.valueOf(lastYear);
            map.put("mgryear", mgryear);
        }
        //处理对应id数据
        Map<String, Object> mapdataType = new HashMap<>();
        mapdataType.put("region", region);
        mapdataType.put("sydLevels", sydLevels);
        List<Map<String, Object>> idmapList = new ArrayList<>();
        List<String> drid = new ArrayList<>();
        if (dataTypeid != null && "1".equals(dataTypeid)) {
            mapdataType.put("CountyCode", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectCountyCodeName(mapdataType);//区划
        }
        if (dataTypeid != null && "2".equals(dataTypeid)) {
            mapdataType.put("segmentCategory", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectDrinksourceTypeName(mapdataType);//类型
        }
        if (dataTypeid != null && "3".equals(dataTypeid)) {
            mapdataType.put("segmentCategory", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectDrinkSourceName(mapdataType);//级别

        }
        if (idmapList != null && idmapList.size() > 0) {
            for (Map<String, Object> data : idmapList) {
                Object id = data.get("id");
                Object pId = data.get("pId");
                if (pId != null && !"".equals(pId)) {
                    boolean contains = drid.contains(id);
                    if (contains) {
                    } else {
                        drid.add(String.valueOf(id));
                    }
                }
            }
        }
        map.put("drinkSourceIDs", drid);
        if (drid != null && drid.size() > 0) {
            //查询区划和对应保护区建设完成率
            List<Map<String, Object>> bhqjswcllist = manualStatisticsMapper.basDrinksourceProtectAreaConstruction(map);
            //监测监控完成率
            List<Map<String, Object>> jcjkwcl = manualStatisticsMapper.jcjkwcl(map);
            //保护区整治率
            List<Map<String, Object>> bhqzzl = manualStatisticsMapper.bhqzzl(map);
            //风险管理指标完成率
            List<Map<String, Object>> fxglzbl = manualStatisticsMapper.fxglzbl(map);
            //应急管理指标完成率
            List<Map<String, Object>> yjglzbl = manualStatisticsMapper.yjglzbl(map);
            //管理制度完成率
            List<Map<String, Object>> glzdzbl = manualStatisticsMapper.glzdzbl(map);
            if (bhqjswcllist != null && bhqjswcllist.size() > 0) {
                for (Map<String, Object> data : bhqjswcllist) {
                    Map<String, Object> mapdata = new HashMap<>();
                    Object county = data.get("county");//区划
                    Object countyCode = data.get("countyCode");//区划
                    Object province = data.get("province");//省级
                    Object provinceCode = data.get("provinceCode");//
                    Object drinkSourceId = data.get("drinkSourceID");//水源地id
                    Object drinkName = data.get("drinkSourceName");//水源地名称

                    Object isDivide = data.get("isDivideName");//保护区划分率
                    Object isSettingFlag = data.get("isSettingFlagName");//保护区标志设置完成率
                    Object alreadyPartition = data.get("alreadyPartitionName");//一级保护区隔离完成率
                    //保护区建设完成率
                    mapdata.put("county", county);
                    mapdata.put("countyCode", countyCode);
                    mapdata.put("province", province);
                    mapdata.put("provinceCode", provinceCode);
                    mapdata.put("drinkSourceId", drinkSourceId);
                    mapdata.put("drinkSourceName", drinkName);

                    if (null != isDivide) {
                        mapdata.put("isDivide", isDivide);
                    } else {
                        mapdata.put("isDivide", "0.00");
                    }

                    //mapdata.put("isSettingFlagSize",isSettingFlagSize);
                    if (null != isSettingFlag) {
                        mapdata.put("isSettingFlag", isSettingFlag);
                    } else {
                        mapdata.put("isSettingFlag", "0.00");
                    }
                    //mapdata.put("alreadyPartitionSize",alreadyPartitionSize);
                    if (null != alreadyPartition) {
                        mapdata.put("alreadyPartition", alreadyPartition);
                    } else {
                        mapdata.put("alreadyPartition", "0.00");
                    }
                    //监测监控完成率
                    Double dbWE = 0.0;
                    Double dbVS = 0.0;
                    Double dbMI = 0.0;
                    Double dbWM = 0.0;
                    if (jcjkwcl != null && jcjkwcl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> jcjkwcllist = jcjkwcl.stream()
                                .filter(item -> item.get("drinkSourceId").equals(drinkSourceId)

                                )
                                .collect(Collectors.toList());
                        //数据相加为区划对应完成率计算
                        if (jcjkwcllist != null && jcjkwcllist.size() > 0) {
                            for (Map<String, Object> jc : jcjkwcllist) {
                                Object drinksourceTypesName = jc.get("drinksourceTypesName");//类型名称
                                Object drinksourceTypes = jc.get("drinksourceTypes");//类型编码
                                Object we = jc.get("we");//预警监控状况
                                Object vs = jc.get("vs");//视频监控状况
                                Object mi = jc.get("mi");//常规监测状况
                                if (we != null && !"".equals(we)) {
                                    Double aDouble = Double.valueOf(String.valueOf(we));
                                    dbWE = dbWE + aDouble;
                                }
                                if (vs != null && !"".equals(vs)) {
                                    Double aDouble = Double.valueOf(String.valueOf(vs));
                                    dbVS = dbVS + aDouble;
                                }
                                if (mi != null && !"".equals(mi)) {
                                    Double aDouble = Double.valueOf(String.valueOf(mi));
                                    dbMI = dbMI + aDouble;
                                }
                            }
                        }
                        dbWM = drinksourceFormula.monitoringCapability(dbWE, dbVS, dbMI);
                    }
                    mapdata.put("jcjk", df.format(dbWM));

                    //保护区整治率
                    double pcr1Result = 0;
                    double pcr2Result = 0;
                    double pcqrResult = 0;
                    if (bhqzzl != null && bhqzzl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> bhqzzllist = bhqzzl.stream()
                                .filter(item -> item.get("drinkSourceId").equals(drinkSourceId)

                                )
                                .collect(Collectors.toList());

                        //一级保护区
                        double pcr1 = 0;
                        //二级保护区
                        double pcr2 = 0;
                        //准保护区
                        double pcqr = 0;

                        if (bhqzzllist != null && bhqzzllist.size() > 0) {
                            for (Map<String, Object> bhqzzldata : bhqzzllist) {
                                //一级保护区整治率为下面三项算术平均值
                                //建设项目拆除完成率 BCR1、排污口关闭完成率 DCR1 和网箱养殖拆除完成率 CBR1 等三项指标。
                                double bcr1 = Double.parseDouble(String.valueOf(bhqzzldata.get("BCR1")));
                                double dcr1 = Double.parseDouble(String.valueOf(bhqzzldata.get("DCR1")));
                                double cbr1 = Double.parseDouble(String.valueOf(bhqzzldata.get("CBR1")));
                                //单个水源一级保护整治率求和
                                pcr1 = pcr1 + (bcr1 + dcr1 + cbr1) / 3;
                                //二级保护区整治率为下面四项算术平均值
                                //保护区内排污口关闭完成率 DCR2、分散式生活污水处理完成率,DDSR2、分散式畜禽养殖废物综合利用完成率 LWUR2 和网箱养殖整治完成率 CRR2
                                double ddsr2 = Double.parseDouble(String.valueOf(bhqzzldata.get("DDSR2")));
                                double dcr2 = Double.parseDouble(String.valueOf(bhqzzldata.get("DCR2")));
                                double lwur2 = Double.parseDouble(String.valueOf(bhqzzldata.get("LWUR2")));
                                double crr2 = Double.parseDouble(String.valueOf(bhqzzldata.get("CRR2")));
                                //单个水源二级保护整治率求和
                                pcr2 = pcr2 + (ddsr2 + dcr2 + lwur2 + crr2) / 4;
                                //准保护区整治率为下面三项算术平均值
                                //包括工业污染源,（含工业园区）废水达标排放率 WRSRi、准保护区内水污染物排放总量削减完成率 TCWRi,及水源涵养林建设完成率 WCR
                                double wrsr = Double.parseDouble(String.valueOf(bhqzzldata.get("WRSR")));
                                double tcwr = Double.parseDouble(String.valueOf(bhqzzldata.get("TCWR")));
                                double wcr = Double.parseDouble(String.valueOf(bhqzzldata.get("WCR")));
                                //单个水源准保护区整治率求和
                                pcqr = pcqr + (wrsr + tcwr + wcr) / 3;
                            }
                        }


                        if (0 != pcr1) {
                            pcr1Result = pcr1 / bhqzzllist.size();
                        }
                        if (0 != pcr2) {
                            pcr2Result = pcr2 / bhqzzllist.size();
                        }
                        if (0 != pcqr) {
                            pcqrResult = pcqr / bhqzzllist.size();
                        }
                    }
                    mapdata.put("pcr1", df.format(pcr1Result));
                    mapdata.put("pcr2", df.format(pcr2Result));
                    mapdata.put("pcqr", df.format(pcqrResult));
                    //风险管理指标完成率
                    double rmrs = 0;
                    if (fxglzbl != null && fxglzbl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> fxglzbllist = fxglzbl.stream()
                                .filter(item -> item.get("drinkSourceId").equals(drinkSourceId)

                                )
                                .collect(Collectors.toList());

                        Double rmr = 0.0;
                        for (Map<String, Object> fxglzbldata : fxglzbllist) {
                            rmr = rmr + Double.valueOf(String.valueOf(fxglzbldata.get("rmr")));
                        }
                        rmrs = rmr / fxglzbl.size();
                    }
                    mapdata.put("rmrs", df.format(rmrs));

                    //应急管理指标完成率
                    double onemes = 0.00;
                    if (yjglzbl != null && yjglzbl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> yjglzbllist = yjglzbl.stream()
                                .filter(item -> item.get("drinkSourceId").equals(drinkSourceId)

                                )
                                .collect(Collectors.toList());
                        //总完成率
                        double oneme = 0;
                        //水源地数量
                        int oncount = 0;
                        for (Map<String, Object> yjglzbldata : yjglzbllist) {
                            if (null != yjglzbldata.get("dktype").toString()) {
                                oncount = oncount + 1;
                                double aa = Double.parseDouble(yjglzbldata.get("eme").toString());
                                oneme = oneme + aa;
                            }
                        }

                        if (0 != oneme) {
                            onemes = ((oneme / oncount) + 100) / 2;
                        }
                    }
                    mapdata.put("yjgl", df.format(onemes));

                    //管理制度完成率
                    double msrs = 0;
                    if (glzdzbl != null && glzdzbl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> glzdzbllist = glzdzbl.stream()
                                .filter(item -> item.get("drinkSourceId").equals(drinkSourceId)

                                )
                                .collect(Collectors.toList());

                        Double msr = 0.0;

                        for (Map<String, Object> glzdzbldata : glzdzbllist) {
                            if (null != glzdzbldata.get("msr")) {
                                msr = msr + Double.valueOf(String.valueOf(glzdzbldata.get("msr")));

                            }
                        }
                        msrs = msr / glzdzbl.size();
                    }
                    mapdata.put("msrs", df.format(msrs));
                    list.add(mapdata);
                }
            }
        }
        return list;
    }

    @Override
    public List<Map<String, Object>> SummaryEnvironmentalManagement(Map<String, Object> map) {
        List<Map<String, Object>> list = new ArrayList<>();
        // 创建一个DecimalFormat对象，指定格式为两位小数
        DecimalFormat dr = new DecimalFormat("0.00");
        //处理数据id
        //默认根据区划查询
        map.put("dataTypeid", "1");
        Object drinkSourceName = map.get("drinkSourceName");
        Object drinkSourceTyep = map.get("drinksourceType");
        Object dataTypeid = map.get("dataTypeid");
        Object mgryear = map.get("mgryear");
        Object region = map.get("region");
        //如果年份为空默认查询最新的年份数据
        if (mgryear != null && !"".equals(mgryear)) {

        } else {
            Calendar calendar = Calendar.getInstance();
            int currentYear = calendar.get(Calendar.YEAR);
            int lastYear = currentYear - 1;
            mgryear = String.valueOf(lastYear);
            map.put("mgryear", mgryear);
        }
        //处理对应id数据
        Map<String, Object> mapdataType = new HashMap<>();
        mapdataType.put("region", region);
        mapdataType.put("sydLevels", map.get("sydLevels"));
        List<Map<String, Object>> idmapList = new ArrayList<>();
        List<String> drid = new ArrayList<>();
        if (dataTypeid != null && "1".equals(dataTypeid)) {
            mapdataType.put("CountyCode", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectCountyCodeName(mapdataType);//区划
        }
        if (dataTypeid != null && "2".equals(dataTypeid)) {
            mapdataType.put("segmentCategory", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectDrinksourceTypeName(mapdataType);//类型
        }
        if (dataTypeid != null && "3".equals(dataTypeid)) {
            mapdataType.put("segmentCategory", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectDrinkSourceName(mapdataType);//级别

        }
        if (idmapList != null && idmapList.size() > 0) {
            for (Map<String, Object> data : idmapList) {
                Object id = data.get("id");
                Object pId = data.get("pId");
                if (pId != null && !"".equals(pId)) {
                    boolean contains = drid.contains(id);
                    if (contains) {
                    } else {
                        drid.add(String.valueOf(id));
                    }
                }
            }
        }
        map.put("drinkSourceIDs", drid);
        if (drid != null && drid.size() > 0) {
            //查询区划和对应保护区建设完成率
            List<Map<String, Object>> basDrinksourceProtectAreajswcllist = manualStatisticsMapper.basDrinksourceProtectAreajswcl(map);
            //监测监控完成率
            List<Map<String, Object>> jcjkwcl = manualStatisticsMapper.jcjkwcl(map);
            //保护区整治率
            List<Map<String, Object>> bhqzzl = manualStatisticsMapper.bhqzzl(map);
            //风险管理指标完成率
            List<Map<String, Object>> fxglzbl = manualStatisticsMapper.fxglzbl(map);
            //应急管理指标完成率
            List<Map<String, Object>> yjglzbl = manualStatisticsMapper.yjglzbl(map);
            //管理制度完成率
            List<Map<String, Object>> glzdzbl = manualStatisticsMapper.glzdzbl(map);


            if (basDrinksourceProtectAreajswcllist != null && basDrinksourceProtectAreajswcllist.size() > 0) {
                for (Map<String, Object> data : basDrinksourceProtectAreajswcllist) {
                    Map<String, Object> mapdata = new HashMap<>();
                    Object county = data.get("County");//区划
                    Object countyCode = data.get("CountyCode");//区划
                    Object province = data.get("Province");//省级
                    Object provinceCode = data.get("ProvinceCode");//
                    Object size = data.get("size");//对应区划总数量
                    Object dbsize = data.get("dbsize");//对应区划总数量地表
                    Object dxsize = data.get("dxsize");//对应区划总数量 地下
                    Object isDivideSize = data.get("isDivideSize");//保护区划分数量
                    Object isDivide = data.get("isDivide");//保护区完成率
                    Object isSettingFlagSize = data.get("isSettingFlagSize");//保护区标志设计数量
                    Object isSettingFlag = data.get("isSettingFlag");//保护区标志设置完成率
                    Object alreadyPartitionSize = data.get("alreadyPartitionSize");//一级保护区隔离数量
                    Object alreadyPartition = data.get("alreadyPartition");//一级保护区隔离完成率
                    //保护区建设完成率
                    mapdata.put("county", county);
                    mapdata.put("countyCode", countyCode);
                    mapdata.put("province", province);
                    mapdata.put("provinceCode", provinceCode);
                    mapdata.put("size", size);
                    mapdata.put("dbsize", dbsize);
                    mapdata.put("dxsize", dxsize);
                    mapdata.put("isDivideSize", isDivideSize);
                    if (null != isDivide) {
                        mapdata.put("isDivide", isDivide);
                    } else {
                        mapdata.put("isDivide", "0.00");
                    }

                    mapdata.put("isSettingFlagSize", isSettingFlagSize);
                    if (null != isSettingFlag) {
                        mapdata.put("isSettingFlag", isSettingFlag);
                    } else {
                        mapdata.put("isSettingFlag", "0.00");
                    }
                    mapdata.put("alreadyPartitionSize", alreadyPartitionSize);
                    if (null != alreadyPartition) {
                        mapdata.put("alreadyPartition", alreadyPartition);
                    } else {
                        mapdata.put("alreadyPartition", "0.00");
                    }
                    //监测监控完成率
                    Double dxWM = 0.0;
                    Double dbWM = 0.0;
                    if (jcjkwcl != null && jcjkwcl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> jcjkwcllist = jcjkwcl.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());
                        //数据相加为区划对应完成率计算
                        //地表水
                        Double dbWE = 0.0;
                        Double dbVS = 0.0;
                        Double dbMI = 0.0;

                        //地下水
                        Double dxWE = 0.0;
                        Double dxVS = 0.0;
                        Double dxMI = 0.0;

                        if (jcjkwcllist != null && jcjkwcllist.size() > 0) {
                            for (Map<String, Object> jc : jcjkwcllist) {
                                Object drinksourceTypesName = jc.get("drinksourceTypesName");//类型名称
                                Object drinksourceTypes = jc.get("drinksourceTypes");//类型编码
                                Object we = jc.get("we");//预警监控状况
                                Object vs = jc.get("vs");//视频监控状况
                                Object mi = jc.get("mi");//常规监测状况
                                if (we != null && !"".equals(we)) {
                                    Double aDouble = Double.valueOf(String.valueOf(we));
                                    if (drinksourceTypes != null && "0".equals(drinksourceTypes)) {
                                        dbWE = dbWE + aDouble;
                                    }
                                    if (drinksourceTypes != null && "1".equals(drinksourceTypes)) {
                                        dxWE = dxWE + aDouble;
                                    }
                                }
                                if (vs != null && !"".equals(vs)) {
                                    Double aDouble = Double.valueOf(String.valueOf(vs));
                                    if (drinksourceTypes != null && "0".equals(drinksourceTypes)) {
                                        dbVS = dbVS + aDouble;
                                    }
                                    if (drinksourceTypes != null && "1".equals(drinksourceTypes)) {
                                        dxVS = dxVS + aDouble;
                                    }

                                }
                                if (mi != null && !"".equals(mi)) {
                                    Double aDouble = Double.valueOf(String.valueOf(mi));
                                    if (drinksourceTypes != null && "0".equals(drinksourceTypes)) {
                                        dbMI = dbMI + aDouble;
                                    }
                                    if (drinksourceTypes != null && "1".equals(drinksourceTypes)) {
                                        dxMI = dxMI + aDouble;
                                    }

                                }

                            }
                        }
                        if (dbsize != null && !"".equals(dbsize)) {
                            Double WE = 0.0;
                            Double VS = 0.0;
                            Double MI = 0.0;
                            WE = dbWE / Double.valueOf(String.valueOf(dbsize));
                            VS = dbVS / Double.valueOf(String.valueOf(dbsize));
                            MI = dbMI / Double.valueOf(String.valueOf(dbsize));
                            dbWM = drinksourceFormula.monitoringCapability(MI, WE, VS);
                        }
                        if (dxsize != null && !"".equals(dxsize)) {
                            Double WE = 0.0;
                            Double VS = 0.0;
                            Double MI = 0.0;
                            WE = dxWE / Double.valueOf(String.valueOf(dxsize));
                            VS = dxVS / Double.valueOf(String.valueOf(dxsize));
                            MI = dxMI / Double.valueOf(String.valueOf(dxsize));
                            dxWM = drinksourceFormula.monitoringCapability(MI, WE, VS);
                        }
                    }
                    mapdata.put("dxWM", dr.format(dxWM));
                    mapdata.put("dbWM", dr.format(dbWM));
                    //保护区整治率
                    double pcr1Result = 0;
                    double pcr2Result = 0;
                    double pcqrResult = 0;
                    if (bhqzzl != null && bhqzzl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> bhqzzllist = bhqzzl.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());

                        //一级保护区
                        double pcr1 = 0;
                        //二级保护区
                        double pcr2 = 0;
                        //准保护区
                        double pcqr = 0;
                        if (bhqzzllist != null && bhqzzllist.size() > 0) {
                            for (Map<String, Object> bhqzzldata : bhqzzllist) {
                                //一级保护区整治率为下面三项算术平均值 建设项目拆除完成率 BCR1、排污口关闭完成率 DCR1 和网箱养殖拆除完成率 CBR1 等三项指标。
                                double bcr1 = 0;
                                double dcr1 = 0;
                                double cbr1 = 0;
                                if (null != bhqzzldata.get("BCR1")) {
                                    bcr1 = Double.parseDouble(String.valueOf(bhqzzldata.get("BCR1")));
                                }
                                if (null != bhqzzldata.get("DCR1")) {
                                    dcr1 = Double.parseDouble(String.valueOf(bhqzzldata.get("DCR1")));
                                }
                                if (null != bhqzzldata.get("CBR1")) {
                                    cbr1 = Double.parseDouble(String.valueOf(bhqzzldata.get("CBR1")));
                                }
                                //单个水源一级保护整治率求和
                                pcr1 = pcr1 + (bcr1 + dcr1 + cbr1) / 3;

                                //二级保护区整治率为下面四项算术平均值 保护区内排污口关闭完成率 DCR2、分散式生活污水处理完成率 DDSR2、分散式畜禽养殖废物综合利用完成率 LWUR2 和网箱养殖整治完成率 CRR2
                                double ddsr2 = 0;
                                double dcr2 = 0;
                                double lwur2 = 0;
                                double crr2 = 0;
                                if (null != bhqzzldata.get("DDSR2")) {
                                    ddsr2 = Double.parseDouble(String.valueOf(bhqzzldata.get("DDSR2")));
                                }
                                if (null != bhqzzldata.get("DCR2")) {
                                    dcr2 = Double.parseDouble(String.valueOf(bhqzzldata.get("DCR2")));
                                }
                                if (null != bhqzzldata.get("LWUR2")) {
                                    lwur2 = Double.parseDouble(String.valueOf(bhqzzldata.get("LWUR2")));
                                }
                                if (null != bhqzzldata.get("CRR2")) {
                                    crr2 = Double.parseDouble(String.valueOf(bhqzzldata.get("CRR2")));
                                }
                                //单个水源二级保护整治率求和
                                pcr2 = pcr2 + (ddsr2 + dcr2 + lwur2 + crr2) / 4;

                                //准保护区整治率为下面三项算术平均值 包括工业污染源（含工业园区）废水达标排放率 WRSRi、准保护区内水污染物排放总量削减完成率 TCWRi 及水源涵养林建设完成率 WCR
                                double wrsr = 0;
                                double tcwr = 0;
                                double wcr = 0;
                                if (null != bhqzzldata.get("WRSR")) {
                                    wrsr = Double.parseDouble(String.valueOf(bhqzzldata.get("WRSR")));
                                }
                                if (null != bhqzzldata.get("TCWR")) {
                                    tcwr = Double.parseDouble(String.valueOf(bhqzzldata.get("TCWR")));
                                }
                                if (null != bhqzzldata.get("WCR")) {
                                    wcr = Double.parseDouble(String.valueOf(bhqzzldata.get("WCR")));
                                }
                                //单个水源准保护区整治率求和
                                pcqr = pcqr + (wrsr + tcwr + wcr) / 3;
                            }
                        }


                        if (0 != pcr1) {
                            pcr1Result = pcr1 / bhqzzllist.size();
                        }
                        if (0 != pcr2) {
                            pcr2Result = pcr2 / bhqzzllist.size();
                        }
                        if (0 != pcqr) {
                            pcqrResult = pcqr / bhqzzllist.size();
                        }
                    }
                    mapdata.put("pcr1", dr.format(pcr1Result));
                    mapdata.put("pcr2", dr.format(pcr2Result));
                    mapdata.put("pcqr", dr.format(pcqrResult));
                    //风险管理指标完成率
                    double rmrs = 0.0;
                    if (fxglzbl != null && fxglzbl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> fxglzbllist = fxglzbl.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());

                        Double rmr = 0.0;
                        for (Map<String, Object> fxglzbldata : fxglzbllist) {
                            rmr = rmr + Double.valueOf(String.valueOf(fxglzbldata.get("rmr")));
                        }
                        rmrs = rmr / fxglzbl.size();
                    }
                    mapdata.put("rmrs", dr.format(rmrs));

                    //应急管理指标完成率
                    //地表水完成率
                    double onemes = 0.00;
                    //地下水完成率
                    double inemes = 0.00;
                    if (yjglzbl != null && yjglzbl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> yjglzbllist = yjglzbl.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());
                        //地表水总完成率
                        double oneme = 0;
                        //地下水总完成率
                        double ineme = 0;
                        //地表水水源地数量
                        int oncount = 0;
                        //地下水水源地数量
                        int incount = 0;
                        for (Map<String, Object> yjglzbldata : yjglzbllist) {
                            if (null != yjglzbldata.get("dktype").toString()) {
                                if (1 == Integer.parseInt(yjglzbldata.get("dktype").toString())) {
                                    oncount = oncount + 1;
                                    double aa = Double.parseDouble(yjglzbldata.get("eme").toString());
                                    oneme = oneme + aa;
                                } else {
                                    incount = incount + 1;
                                    double aa = Double.parseDouble(yjglzbldata.get("eme").toString());
                                    ineme = ineme + aa;
                                }
                            }
                        }

                        if (0 != oneme) {
                            onemes = ((oneme / oncount) + 100) / 2;
                        }
                        if (0 != ineme) {
                            inemes = ((ineme / incount) + 100) / 2;
                        }
                    }
                    mapdata.put("onemes", dr.format(onemes));
                    mapdata.put("inemes", dr.format(inemes));
                    //管理制度完成率
                    double msrs = 0.0;
                    if (glzdzbl != null && glzdzbl.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> glzdzbllist = glzdzbl.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());

                        Double msr = 0.0;

                        for (Map<String, Object> glzdzbldata : glzdzbllist) {
                            if (null != glzdzbldata.get("msr")) {
                                msr = msr + Double.valueOf(String.valueOf(glzdzbldata.get("msr")));

                            }
                        }
                        msrs = msr / glzdzbl.size();
                    }
                    mapdata.put("msrs", dr.format(msrs));

                    list.add(mapdata);
                }
            }
        }
        return list;
    }

    @Override
    public List<Map<String, Object>> getWaterDrinkSource(Map<String, Object> map) {
        List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
        DecimalFormat df = new DecimalFormat("0.00");

        if (null != map.get("mgryear")) {
            //当年取水量保证率
            List<Map<String, Object>> qsthisYear = manualStatisticsMapper.getWaterAssuranceRate(map);
            //上一年年取水量保证率
            Map<String, Object> newMap = new HashMap<String, Object>();
            newMap.put("mgryear", Integer.parseInt(map.get("mgryear").toString()) - 1);
            newMap.put("sydLevels", map.get("sydLevels"));
            List<Map<String, Object>> qslastYear = manualStatisticsMapper.getWaterAssuranceRate(newMap);
            //当年水量达标率
            List<Map<String, Object>> slthisYear = manualStatisticsMapper.getWaterReachStandard(map);
            //上一年水量达标率
            List<Map<String, Object>> sllastYear = manualStatisticsMapper.getWaterReachStandard(newMap);

            Map<String, Object> alldrinkmaps = new HashMap<>();
            alldrinkmaps.put("isOverStandard3", "0");
            alldrinkmaps.put("beginTime", map.get("mgryear").toString() + "-01");
            alldrinkmaps.put("endTime", map.get("mgryear").toString() + "-12");
            alldrinkmaps.put("sydLevels", map.get("sydLevels"));
            //查询水源地监测根据区划划分的监测数量（全部/达标）
            List<Map<String, Object>> drinksourceCountyList = manualStatisticsMapper.drinksourceCountyCodealldb(alldrinkmaps);

            alldrinkmaps.put("isOverStandard3", "");
            List<Map<String, Object>> alldrinksourceCountyList = manualStatisticsMapper.drinksourceCountyCodealldb(alldrinkmaps);

            Map<String, Object> alldrinkmaps1 = new HashMap<>();
            alldrinkmaps1.put("isOverStandard3", "0");
            alldrinkmaps1.put("beginTime", (Integer.parseInt(map.get("mgryear").toString()) - 1) + "-01");
            //    alldrinkmaps.put("qsItemCode","A2275767-FE7C-466D-83F1-D9D04A18C78D");
            alldrinkmaps1.put("endTime", (Integer.parseInt(map.get("mgryear").toString()) - 1) + "-12");
            alldrinkmaps1.put("sydLevels", map.get("sydLevels"));
            //查询水源地监测根据区划划分的监测数量（全部/达标）
            List<Map<String, Object>> lastdrinksourceCountyList = manualStatisticsMapper.drinksourceCountyCodealldb(alldrinkmaps1);

            alldrinkmaps1.put("isOverStandard3", "");
            List<Map<String, Object>> lastalldrinksourceCountyList = manualStatisticsMapper.drinksourceCountyCodealldb(alldrinkmaps1);

            //获取水源地数量变化个数
            mapList = manualStatisticsMapper.getWaterDrinkSource(map);
            if (null != mapList && mapList.size() > 0) {
                for (Map<String, Object> map2 : mapList) {
                    Object countyCode = map2.get("CountyCode");
                    //当年取水量保证率
                    Double qsthisYearWgr = 0.0;
                    if (null != qsthisYear && qsthisYear.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> thisYearlist = qsthisYear.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());
                        Double qsallthisYear = 0.0;
                        if (null != thisYearlist && thisYearlist.size() > 0) {
                            for (Map<String, Object> jc : thisYearlist) {
                                Object vs = jc.get("quwater");
                                Double aDouble = Double.valueOf(String.valueOf(vs));
                                if (vs != null && !"".equals(vs)) {
                                    qsallthisYear = qsallthisYear + aDouble;
                                }
                            }
                            //计算取水量保证率，取水量保证率总值/水源地个数
                            if (qsallthisYear > 0) {
                                qsthisYearWgr = qsallthisYear / thisYearlist.size();
                            }
                        }

                    }
                    map2.put("qsthisYearWgr", df.format(qsthisYearWgr));
                    //上年取水量保证率
                    Double qslastYearWgr = 0.0;
                    if (null != qslastYear && qslastYear.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> lastYearlist = qslastYear.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());
                        Double qsalllastYear = 0.0;
                        if (null != lastYearlist && lastYearlist.size() > 0) {
                            for (Map<String, Object> jc : lastYearlist) {
                                Object vs = jc.get("quwater");
                                Double aDouble = Double.valueOf(String.valueOf(vs));
                                if (vs != null && !"".equals(vs)) {
                                    qsalllastYear = qsalllastYear + aDouble;
                                }
                            }
                            //计算取水量保证率，取水量保证率总值/水源地个数
                            if (qsalllastYear > 0) {
                                qslastYearWgr = qsalllastYear / lastYearlist.size();
                            }
                        }
                    }
                    map2.put("qslastYearWgr", df.format(qslastYearWgr));

                    //当年水量达标率
                    Double slthisYearWsr = 0.0;
                    Double sydbthisYearWqr = 0.0;
                    if (null != slthisYear && slthisYear.size() > 0) {
                        //数据分组
                        List<Map<String, Object>> thisYearlist = slthisYear.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());

                        //达标数量
                        List<Map<String, Object>> dblist = thisYearlist.stream()
                                .filter(item -> item.get("isover").equals("0")

                                )
                                .collect(Collectors.toList());


                        //达标取水量
                        Double sldb = 0.0;
                        //总取水量
                        Double slall = 0.0;
                        if (null != thisYearlist && thisYearlist.size() > 0) {
                            for (Map<String, Object> jc : thisYearlist) {
                                Object vs = jc.get("effectiveValue");
                                Double aDouble = Double.valueOf(String.valueOf(vs));
                                if (vs != null && !"".equals(vs)) {
                                    slall = slall + aDouble;
                                }
                            }
                            if (null != dblist && dblist.size() > 0) {
                                for (Map<String, Object> jc : dblist) {
                                    Object vs = jc.get("effectiveValue");
                                    Double aDouble = Double.valueOf(String.valueOf(vs));
                                    if (vs != null && !"".equals(vs)) {
                                        sldb = sldb + aDouble;
                                    }
                                }
                                //水量达标率：达标取水总量/总取水量
                                slthisYearWsr = (sldb / slall) * 100;
                            }
                        }
                    }
                    //
                    map2.put("slthisYearWsr", df.format(slthisYearWsr));
                    int nowsize = 0, lastsize = 0;
                    //数据分组
                    if (drinksourceCountyList != null && drinksourceCountyList.size() > 0) {

                        List<Map<String, Object>> drinksourceCountyList1 = drinksourceCountyList.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());
                        nowsize = drinksourceCountyList1.size();

                    }
                    if (alldrinksourceCountyList != null && alldrinksourceCountyList.size() > 0) {
                        List<Map<String, Object>> alldrinksourceCountyList1 = alldrinksourceCountyList.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());
                        lastsize = alldrinksourceCountyList1.size();
                    }

                    sydbthisYearWqr = lastsize == 0 ? 0 : (Double.valueOf(nowsize) / Double.valueOf(lastsize)) * 100;
                    map2.put("sydbthisYearWqr", df.format(sydbthisYearWqr));
                    //上一年水量达标率
                    Double sllastYearWsr = 0.0;
                    Double sydblastYearWqr = 0.0;
                    if (null != sllastYear && !sllastYear.isEmpty()) {
                        //数据分组
                        List<Map<String, Object>> lastYearlist = sllastYear.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());

                        //达标数据分组
                        List<Map<String, Object>> dblist = lastYearlist.stream()
                                .filter(item -> item.get("isover").equals("0")

                                )
                                .collect(Collectors.toList());

                        //达标取水量
                        Double sldb = 0.0;
                        //总取水量
                        Double slall = 0.0;
                        if (null != lastYearlist && lastYearlist.size() > 0) {
                            for (Map<String, Object> jc : lastYearlist) {
                                Object vs = jc.get("effectiveValue");
                                Double aDouble = Double.valueOf(String.valueOf(vs));
                                if (vs != null && !"".equals(vs)) {
                                    slall = slall + aDouble;
                                }
                            }
                            if (null != dblist && dblist.size() > 0) {
                                for (Map<String, Object> jc : dblist) {
                                    Object vs = jc.get("effectiveValue");
                                    Double aDouble = Double.valueOf(String.valueOf(vs));
                                    if (vs != null && !"".equals(vs)) {
                                        sldb = sldb + aDouble;
                                    }
                                }
                                //水量达标率：达标取水总量/总取水量
                                sllastYearWsr = (sldb / slall) * 100;
                            }

                        }
                    }
                    map2.put("sllastYearWsr", df.format(sllastYearWsr));
                    int sizenow = 0, sizelast = 0;
                    if (lastdrinksourceCountyList != null && lastdrinksourceCountyList.size() > 0) {
                        List<Map<String, Object>> lastdrinksourceCountyList1 = lastdrinksourceCountyList.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)

                                )
                                .collect(Collectors.toList());
                        sizenow = lastdrinksourceCountyList1.size();
                    }
                    if (lastalldrinksourceCountyList != null && lastalldrinksourceCountyList.size() > 0) {

                        List<Map<String, Object>> lastalldrinksourceCountyList1 = lastalldrinksourceCountyList.stream()
                                .filter(item -> item.get("CountyCode").equals(countyCode)
                                )
                                .collect(Collectors.toList());
                        sizelast = lastalldrinksourceCountyList1.size();
                    }
                    sydblastYearWqr = sizelast == 0 ? 0 : (Double.valueOf(sizenow) / Double.valueOf(sizelast)) * 100;
                    map2.put("sydblastYearWqr", df.format(sydblastYearWqr));
                }
            }
        }
        return mapList;
    }

    @Override
    public List<Map<String, Object>> isoverDrinkSourcelist(Map<String, Object> map) {

        List<Map<String, Object>> list = new ArrayList<>();
        DecimalFormat df = new DecimalFormat("#0.00");
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Object drinksourceType = map.get("drinksourceType");
        Object drinkSourceLevel = map.get("drinkSourceLevel");
        Object countyCode = map.get("countyCode");
        Object drinkSourceName = map.get("drinkSourceName");
        Object dataTypeid = map.get("dataTypeid");
        Object dataType = map.get("dataType");
        Object beginTime = map.get("beginTime");
        Object endTime = map.get("endTime");

        Map<String, Object> mapdataType = new HashMap<>();
        List<Map<String, Object>> idmapList = new ArrayList<>();
        if (null != dataType && "0".equals(dataType.toString())) {
            mapdataType.put("IsOverStandard3", "0");
        } else if (null != dataType && "1".equals(dataType.toString())) {
            mapdataType.put("IsOverStandard3", "1");
        }
        mapdataType.put("dataType", dataType);
        mapdataType.put("beginTime", beginTime);
        mapdataType.put("endTime", endTime);
        Object drinkSourceTyep = map.get("drinksourceType");
        List<String> drid = new ArrayList<>();
        if (dataTypeid != null && "1".equals(dataTypeid)) {
            mapdataType.put("CountyCode", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectCountyCodeNameV2(mapdataType);//区划
        }
        if (dataTypeid != null && "2".equals(dataTypeid)) {
            mapdataType.put("segmentCategory", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectDrinksourceTypeNameV2(mapdataType);//类型
        }
        if (dataTypeid != null && "3".equals(dataTypeid)) {
            mapdataType.put("segmentCategory", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            idmapList = manualStatisticsMapper.selectDrinkSourceNameV2(mapdataType);//级别

        }
        if (idmapList != null && idmapList.size() > 0) {
            for (Map<String, Object> data : idmapList) {
                Object id = data.get("id");
                Object pId = data.get("pId");
                if (pId != null && !"".equals(pId)) {
                    boolean contains = drid.contains(id);
                    if (contains) {
                    } else {
                        drid.add(String.valueOf(id));
                    }
                }
            }
        }
        //查询对应标准值
        List<Map<String, Object>> sectionStandardCalculationlist = new ArrayList<>();
        Map<String, Object> getbasicsmonitordatamap = new HashMap<>();
        List<Map> sectionStandardCalculationlists = publicToolsMapper.sectionStandardCalculation(getbasicsmonitordatamap);
        if (sectionStandardCalculationlists != null && sectionStandardCalculationlists.size() > 0) {
            for (Map daya : sectionStandardCalculationlists) {
                sectionStandardCalculationlist.add(daya);
            }
        }
        //查询对应因子修约位数
        Map<String, Object> itemap = new HashMap<>();
        itemap.put("IsEvalute", "1");
        List<Map<String, Object>> wqCodBussinessitemsbussinessCategoryCodelist = publicToolsMapper.wqCodBussinessitemsbussinessCategoryCode(itemap);

        //获取取水量
        map.put("SegmentIDs", drid);
        List<Map<String, Object>> qslSUMeffectiveValuemapList = manualStatisticsMapper.qslSUMeffectiveValue(map);
        Map<String, Object> wqBasDrinksourceIDmap = new HashMap<>();
        wqBasDrinksourceIDmap.put("SegmentIDs", drid);
        //查询全部水源地
        List<Map<String, Object>> stringObjectMaplist = manualStatisticsMapper.wqBasDrinksourceID(wqBasDrinksourceIDmap);
        //取水量和/监测因子均值
        List<Map<String, Object>> jcsjAvgeffectiveValueseList = manualStatisticsMapper.jcsjAvgeffectiveValuese(map);

        //超标月份和对应超标因子描述
        List<Map<String, Object>> cbmonTimemapList = manualStatisticsMapper.cbmonTime(map);

        if (drid != null && drid.size() > 0) {
            for (String dataid : drid) {
                Map<String, Object> mapdata = new HashMap<>();
                //查询水源地达标月份
                List<Map<String, Object>> dataListOne = idmapList.stream()
                        .filter(item -> item.get("id").equals(dataid)
                        ).collect(Collectors.toList());
                String dbMonths = "";
                if (dataListOne != null && dataListOne.size() > 0) {
                    for (Map<String, Object> data : dataListOne) {
                        if (!"".equals(dbMonths)) {
                            dbMonths = dbMonths + "," + data.get("sampledate").toString();
                        } else {
                            dbMonths = data.get("sampledate").toString();
                        }
                    }
                }
                mapdata.put("dbMonths", dbMonths);

                //计算
                Integer maxqualityLevel = 0;
                if (jcsjAvgeffectiveValueseList != null && jcsjAvgeffectiveValueseList.size() > 0) {
                    List<Map<String, Object>> sunmapsLevel = jcsjAvgeffectiveValueseList.stream()
                            .filter(item -> item.get("SegmentID").equals(dataid)
                            )
                            .collect(Collectors.toList());

                    List<Map<String, Object>> cbmonTimemapLists = cbmonTimemapList.stream()
                            .filter(item -> item.get("SegmentID").equals(dataid)
                            )
                            .collect(Collectors.toList());

                    if (sunmapsLevel != null && sunmapsLevel.size() > 0) {

                        mapdata.put("type", "");
                        Double syddb = 0.0;
                        Double sldb = 0.0;
                        String drinksourceTypeNametyep = null;
                        String segmentCategory = null;
                        String drinksourceTypes = null;
                        String sampleDatecbstring = null;
                        String overStandardDescribe = null;
                        //处理超标月份和超标因子描述
                        List<String> sampleDatecb = new ArrayList<>();
                        List<String> overStandardDescribe3cb = new ArrayList<>();
                        if (cbmonTimemapLists != null && cbmonTimemapLists.size() > 0) {
                            //超标月份统计
                            String cbMonths = "";
                            for (Map<String, Object> datase : cbmonTimemapLists) {
                                Object sampleDate = datase.get("SampleDate");//超标月份
                                Object overStandardDescribe3 = datase.get("OverStandardDescribe3");//超标因子描述
                                boolean contains = sampleDatecb.contains(sampleDate);
                                boolean containss = overStandardDescribe3cb.contains(overStandardDescribe3);
                                if (contains) {

                                } else {
                                    sampleDatecb.add(String.valueOf(sampleDate));
                                }
                                if (containss) {

                                } else {
                                    overStandardDescribe3cb.add(String.valueOf(overStandardDescribe3));
                                }
                            }
                        }
                        //超标月份统计
                        if (sampleDatecb != null && sampleDatecb.size() > 0) {
                            for (String data : sampleDatecb) {
                                if (sampleDatecbstring != null) {
                                    sampleDatecbstring = sampleDatecbstring + "," + data;
                                } else {
                                    sampleDatecbstring = data;
                                }
                            }

                        }
                        //超标因子统计
                        if (overStandardDescribe3cb != null && overStandardDescribe3cb.size() > 0) {
                            for (String data : overStandardDescribe3cb) {
                                if (overStandardDescribe != null) {
                                    overStandardDescribe = overStandardDescribe + "," + data;
                                } else {
                                    overStandardDescribe = data;
                                }
                            }

                        }
                        mapdata.put("cbMonTime", sampleDatecbstring);
                        mapdata.put("cbOverStandard", overStandardDescribe);
                        if (stringObjectMaplist != null && stringObjectMaplist.size() > 0) {
                            List<Map<String, Object>> stringObjectMaps = stringObjectMaplist.stream()
                                    .filter(item -> item.get("id").equals(dataid)
                                    )
                                    .collect(Collectors.toList());
                            if (stringObjectMaps != null && !"".equals(stringObjectMaps)) {
                                for (Map<String, Object> stringObjectMap : stringObjectMaps) {


                                    Object drinksourceTypeNametyeps = stringObjectMap.get("drinksourceTypeNametyep");
                                    Object DrinkSourceName = stringObjectMap.get("DrinkSourceName");
                                    Object id = stringObjectMap.get("id");
                                    Object drinksourceTypeName = stringObjectMap.get("drinksourceTypeName");
                                    Object DrinksourceType = stringObjectMap.get("DrinksourceType");
                                    Object DrinkSourceLevel = stringObjectMap.get("DrinkSourceLevel");
                                    Object drinkSourceLevelName = stringObjectMap.get("drinkSourceLevelName");
                                    Object drinksourceTypeNmae = stringObjectMap.get("drinksourceTypeNmae");
                                    Object countyCodes = stringObjectMap.get("countyCode");
                                    Object province = stringObjectMap.get("province");
                                    Object lakeName = stringObjectMap.get("lakeName");
                                    Object lakeCode = stringObjectMap.get("lakeCode");
                                    Object provinceCode = stringObjectMap.get("provinceCode");
                                    Object populationCovered = stringObjectMap.get("populationCovered");
                                    Object county = stringObjectMap.get("county");
                                    Object segmentCategorys = stringObjectMap.get("segmentCategory");
                                    segmentCategory = String.valueOf(segmentCategorys);
                                    drinksourceTypes = String.valueOf(DrinksourceType);
                                    mapdata.put("populationCovered", populationCovered);
                                    mapdata.put("county", county);
                                    mapdata.put("province", province);
                                    mapdata.put("targetLevelName", "Ⅲ类");
                                    mapdata.put("targetLevel", "3");
                                    mapdata.put("drinksourceName", DrinkSourceName);
                                    mapdata.put("drinksourceTypeName", drinksourceTypeNmae);
                                    mapdata.put("drinksourceType", DrinksourceType);
                                    mapdata.put("drinksourceId", id);
                                    mapdata.put("drinkSourceLevelName", drinkSourceLevelName);
                                    mapdata.put("provinceCode", provinceCode);
                                    mapdata.put("drinkSourceLevel", DrinkSourceLevel);
                                    mapdata.put("countyCode", countyCode);
                                    if (drinksourceTypeNametyeps != null && !"".equals(drinksourceTypeNametyeps)) {
                                        drinksourceTypeNametyep = String.valueOf(drinksourceTypeNametyeps);
                                    }
                                }


                            }
                        }
                        //获取均值数据
                        //上面数据进行分组处理
                        //取水量数据处理
                        String dbqsl = null;//达标取水量
                        String cbqsl = null;//达标取水量
                        if (qslSUMeffectiveValuemapList != null && qslSUMeffectiveValuemapList.size() > 0) {
                            //达标取水量
                            List<Map<String, Object>> sunmapsLevelse = qslSUMeffectiveValuemapList.stream()
                                    .filter(item -> item.get("SegmentID").equals(dataid)
                                            && item.get("isover").equals("0")
                                    )
                                    .collect(Collectors.toList());
                            //String dbMonths = "";
                            if (sunmapsLevelse != null && sunmapsLevelse.size() > 0) {
                                for (Map<String, Object> data : sunmapsLevelse) {
                                    Object effectiveValue = data.get("effectiveValue");
                                    if (effectiveValue != null && !"".equals(effectiveValue)) {
                                        Double aDouble = Double.valueOf(String.valueOf(effectiveValue));
                                        if (dbqsl != null && !"".equals(dbqsl)) {
                                            double v = Double.valueOf(dbqsl) + aDouble;
                                            dbqsl = String.valueOf(v);
                                        } else {
                                            dbqsl = String.valueOf(aDouble);
                                        }
                                    }
                                }
                            }
                            //超标取水量
                            //达标取水量
                            List<Map<String, Object>> cbsunmapsLevel = qslSUMeffectiveValuemapList.stream()
                                    .filter(item -> item.get("SegmentID").equals(dataid)
                                            && item.get("isover").equals("1")
                                    )
                                    .collect(Collectors.toList());
                            String cbMonths = "";
                            if (cbsunmapsLevel != null && cbsunmapsLevel.size() > 0) {
                                for (Map<String, Object> data : cbsunmapsLevel) {
                                    if (!"".equals(cbMonths)) {
                                        cbMonths = cbMonths + "," + data.get("SampleDate").toString();
                                    } else {
                                        cbMonths = data.get("SampleDate").toString();
                                    }
                                    Object effectiveValue = data.get("effectiveValue");
                                    if (effectiveValue != null && !"".equals(effectiveValue)) {
                                        Double aDouble = Double.valueOf(String.valueOf(effectiveValue));
                                        if (cbqsl != null && !"".equals(cbqsl)) {
                                            double v = Double.valueOf(cbqsl) + aDouble;
                                            cbqsl = String.valueOf(v);
                                        } else {
                                            cbqsl = String.valueOf(aDouble);
                                        }
                                    }
                                }
                            }
                            mapdata.put("cbMonths", cbMonths);
                            mapdata.put("dbqsl", dbqsl == null ? null : df.format(Double.valueOf(dbqsl)));
                            mapdata.put("cbqsl", cbqsl == null ? null : df.format(Double.valueOf(cbqsl)));
                            Double qsl = 0.0;//全部取水量
                            if (dbqsl != null && !"".equals(dbqsl)) {
                                Double aDouble = Double.valueOf(dbqsl);
                                qsl = qsl + aDouble;
                                if (cbqsl != null && !"".equals(cbqsl)) {
                                    Double aDoubles = Double.valueOf(cbqsl);
                                    qsl = qsl + aDoubles;
                                }
                            }
                            //waterVolume 水量达标率
                            //计算水量达标率  达标率 =(达标学生人数/学生总人数)×100%
                            if (qsl != null && !"".equals(qsl) && Double.valueOf(qsl) > 0) {
                                if (dbqsl != null && !"".equals(dbqsl) && Double.valueOf(dbqsl) > 0) {
                                    double vs = (Double.valueOf(dbqsl) / Double.valueOf(qsl)) * 100;
                                    sldb = vs;
                                    mapdata.put("waterVolume", df.format(vs));
                                }
                            } else {
                                mapdata.put("waterVolume", "-");

                            }
                            //mapdata.put("qsl",qsl);
                            mapdata.put("qsl", Double.valueOf(qsl));
                        }

                        if (sunmapsLevel != null && sunmapsLevel.size() > 0) {
                            for (Map<String, Object> data : sunmapsLevel) {
                                Object effectiveValue = data.get("effectiveValue");
                                Object itemCode = data.get("ItemCode");
                                Object ItemName = data.get("ItemName");
                                List<Map<String, Object>> sunmapsLevels = new ArrayList<>();
                                if (wqCodBussinessitemsbussinessCategoryCodelist != null && wqCodBussinessitemsbussinessCategoryCodelist.size() > 0) {
                                    String finalDrinksourceTypeNametyep = drinksourceTypeNametyep;
                                    wqCodBussinessitemsbussinessCategoryCodelist.stream()
                                            .filter(item -> item.get("BussinessCategoryCode").equals(finalDrinksourceTypeNametyep)
                                                    && item.get("ItemCode").equals(itemCode)
                                            )
                                            .collect(Collectors.toList());
                                }
                                //  if(sunmapsLevels!=null&&sunmapsLevels.size()>0){
                                //处理因子数据
                                if (effectiveValue != null && !"".equals(effectiveValue)) {
                                    //判断是否科学计算法，如果是就进行转换
                                    boolean scientificNotation = StringUtils.isScientificNotation(String.valueOf(effectiveValue));
                                    if (scientificNotation) {
                                        BigDecimal bigDecimal = new BigDecimal(String.valueOf(effectiveValue));
                                        String effectiveValuesdatas = bigDecimal.toPlainString();
                                        effectiveValue = effectiveValuesdatas;
                                    } else {
                                        effectiveValue = String.valueOf(effectiveValue);
                                    }
                                }
                                if (ItemName != null && !"".equals(ItemName)) {
                                    //下面进行数据计算和处理
                                    if (effectiveValue != null && !"".equals(effectiveValue) && !"-1".equals(effectiveValue)) {
                                        if (sectionStandardCalculationlist != null && sectionStandardCalculationlist.size() > 0) {
                                            //数据分组  SegmentCategory  ItemCode Level
                                            //分组判断，stream流 //断面类型
                                            List<Map<String, Object>> sunmapsitemCodelist = new ArrayList<>();
                                            Map<String, List<Map<String, Object>>> sunmapsSegmentCategory =
                                                    sectionStandardCalculationlist.stream().collect(
                                                            Collectors.groupingBy(item -> item.get("WaterType").toString())
                                                    );
                                            //SegmentCategorys 断面类型分组
                                            List<Map<String, Object>> sunmapsSegmentCategorylist = sunmapsSegmentCategory.get(String.valueOf(drinksourceTypes));
                                            //因子名称分组
                                            if (sunmapsSegmentCategorylist != null && sunmapsSegmentCategorylist.size() > 0) {
                                                Map<String, List<Map<String, Object>>> sunmapsitemCode =
                                                        sunmapsSegmentCategorylist.stream().collect(
                                                                Collectors.groupingBy(item -> item.get("ItemCode").toString())
                                                        );
                                                sunmapsitemCodelist = sunmapsitemCode.get(itemCode);
                                            }
                                            //断面标准计算进行转换list
                                            List<Standard> Standardlist = new ArrayList<>();
                                            if (sunmapsitemCodelist != null && sunmapsitemCodelist.size() > 0) {
                                                for (Map s : sunmapsitemCodelist) {
                                                    Standard standard = new Standard();//计算标准实体类
                                                    Object waterType = s.get("WaterType");//水体类型
                                                    Object StartDate = s.get("StartDate");//开始时间
                                                    Object EndDate = s.get("EndDate");//结束时间
                                                    Object ItemCodes = s.get("ItemCode");//监测项编码
                                                    Object Level = s.get("Level");//水质级别
                                                    Object CompareMethod = s.get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
                                                    Object StandardValue = s.get("StandardValue");//标准值
                                                    Object Type = s.get("Type");//监测项目标准分类（常规、特殊）
                                                    Object StandardCategory = s.get("StandardCategory");//标准类别（河流/湖库/地下水）
                                                    //下面判读数据不为空进行数据处理到实体类里面
                                                    if (waterType != null && !"".equals(waterType)) {
                                                        standard.setWaterType(String.valueOf(waterType));
                                                    } else {
                                                        standard.setWaterType("");
                                                    }
                                                    if (StartDate != null && !"".equals(StartDate)) {
                                                        String StartDateString = String.valueOf(StartDate);
                                                        Date StartDateStringparse = null;
                                                        try {
                                                            StartDateStringparse = dateFormat.parse(StartDateString);
                                                        } catch (ParseException e) {
                                                            e.printStackTrace();
                                                        }
                                                        standard.setStartDate(StartDateStringparse);
                                                    }
                                                    if (EndDate != null && !"".equals(EndDate)) {
                                                        String EndDateString = String.valueOf(EndDate);
                                                        Date EndDateStringparse = null;
                                                        try {
                                                            EndDateStringparse = dateFormat.parse(EndDateString);
                                                        } catch (ParseException e) {
                                                            e.printStackTrace();
                                                        }
                                                        standard.setEndDate(EndDateStringparse);
                                                    }
                                                    if (ItemCodes != null && !"".equals(ItemCodes)) {
                                                        standard.setItemCode(String.valueOf(ItemCodes));
                                                    } else {
                                                        standard.setItemCode("");
                                                    }
                                                    if (Level != null && !"".equals(Level)) {
                                                        standard.setLevel(String.valueOf(Level));
                                                    } else {
                                                        standard.setLevel("");
                                                    }
                                                    if (StandardValue != null && !"".equals(StandardValue)) {
                                                        standard.setStandardValue(String.valueOf(StandardValue));
                                                    } else {
                                                        standard.setStandardValue("");
                                                    }
                                                    if (Type != null && !"".equals(Type)) {
                                                        standard.setType(String.valueOf(Type));
                                                    } else {
                                                        standard.setType("");
                                                    }
                                                    if (StandardCategory != null && !"".equals(StandardCategory)) {
                                                        standard.setStandardCategory(String.valueOf(StandardCategory));
                                                    } else {
                                                        standard.setStandardCategory("");
                                                    }
                                                    if (CompareMethod != null && !"".equals(CompareMethod)) {
                                                        standard.setCompareMethod(String.valueOf(CompareMethod));
                                                    } else {
                                                        standard.setCompareMethod("");
                                                    }
                                                    Standardlist.add(standard);
                                                }
                                            }
                                            if (itemCode != null && !"6F2E428C-2705-4DC1-A1D8-235CB9330593".equals(itemCode)) {
                                                //计算水质级别
                                                if (effectiveValue != null && !"".equals(effectiveValue) && !"-1".equals(effectiveValue)) {
                                                    Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(effectiveValue)), Standardlist, String.valueOf(itemCode), String.valueOf(effectiveValue), Integer.valueOf(String.valueOf(segmentCategory)));
                                                    //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                                    if (integer != null) {
                                                        integer = integer;//断面计算出的级别
                                                    } else {
                                                        //断面计算出的级别
                                                        integer = 0;
                                                    }
                                                    //转换水质级别名称
                                                    //   String LevelName = WaterLevelCompute.GetLevelName(integer,"");
                                                    if (integer > maxqualityLevel) {
                                                        maxqualityLevel = integer;
                                                    }
                                                }
                                            }

                                        }
                                    }


                                }
                            }
                        }
                        mapdata.put("qualityLevel", maxqualityLevel);//达标率
                        //转换水质级别名称
                        String LevelName = WaterLevelCompute.GetLevelName(maxqualityLevel, null);
                        mapdata.put("qualityLevelName", LevelName);
                        if (maxqualityLevel <= 3) {
                            syddb = 100.0;
                            mapdata.put("isover", "100.00");//达标率
                        } else {
                            mapdata.put("isover", "0");//达标率
                        }
                        String sq = segmentFormula.assessmentOfWater(sldb, syddb);
                        mapdata.put("evaluationScore", sq);
                        String s1 = segmentFormula.assessmentOfWaterresult(Double.valueOf(sq));
                        mapdata.put("evaluationResults", s1);
                        if (mapdata != null && mapdata.size() > 0) {
                            list.add(mapdata);
                        }
                    }
                }
            }
        }
        //去除错误数据
        if (null != dataType && "0".equals(dataType.toString())) {
            list.removeIf(result -> null == result.get("dbMonths") || "".equals(result.get("dbMonths")));
        } else if (null != dataType && "1".equals(dataType.toString())) {
            list.removeIf(result -> null == result.get("cbMonTime") || "".equals(result.get("cbMonTime")));
        }
        return list;
    }

    @Override
    public Map<String, Object> drinkSourcewaterQuality(Map<String, Object> map) {
        Object drinkSourceName = map.get("drinkSourceName");
        Object drinkSourceTyep = map.get("drinksourceType");
        Object dataTypeid = map.get("dataTypeid");
        String beginTime = map.get("beginTime").toString();
        String endTime = map.get("endTime").toString();
        //获取同比时间
        if ("1".equals(map.get("isWhether"))) {
            Map<String, Object> stringObjectMap = DateUtils.OnTheSameMonthRatio(String.valueOf(beginTime), String.valueOf(endTime), "yyyy-MM");
            if (stringObjectMap != null && stringObjectMap.size() > 0) {
                beginTime = (String) stringObjectMap.get("tbksData");
                endTime = (String) stringObjectMap.get("tbjsData");
                map.put("beginTime", beginTime);
                map.put("endTime", endTime);
            }
        }
        Map<String, Object> mapdataType = new HashMap<>();
        List<Map<String, Object>> DrinkSourcesizelsit = new ArrayList<>();
        List<String> drid = new ArrayList<>();
        if (dataTypeid != null && "1".equals(dataTypeid)) {
            //查询条件转换处理
            map.put("countyCode", drinkSourceTyep);
            map.remove("drinksourceType");
            mapdataType.put("CountyCode", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            DrinkSourcesizelsit = manualStatisticsMapper.selectCountyCodeName(mapdataType);//区划
        }
        if (dataTypeid != null && "2".equals(dataTypeid)) {
            mapdataType.put("segmentCategory", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            DrinkSourcesizelsit = manualStatisticsMapper.selectDrinksourceTypeName(mapdataType);//类型
        }
        if (dataTypeid != null && "3".equals(dataTypeid)) {
            //查询条件转换处理
            map.put("drinkSourceLevel", drinkSourceTyep);
            map.remove("drinksourceType");
            mapdataType.put("segmentCategory", drinkSourceTyep);
            mapdataType.put("drinkSourceName", drinkSourceName);
            DrinkSourcesizelsit = manualStatisticsMapper.selectDrinkSourceName(mapdataType);//级别

        }

        List<String> dseid = new ArrayList<>();
        List<String> countyLists = new ArrayList<>();
        List<Map<String, Object>> codelists = new ArrayList<>();
        int size = DrinkSourcesizelsit.size();
        if (DrinkSourcesizelsit != null && DrinkSourcesizelsit.size() > 0) {
            for (Map<String, Object> data : DrinkSourcesizelsit) {

                Object id = data.get("id");
                Object pId = data.get("pId");
                Object countyCode = data.get("CountyCode");
                Object county = data.get("County");
                Map<String, Object> s = new HashMap<>();
                if (county != null && !"".equals(county)) {
                    boolean contains = countyLists.contains(county);
                    if (contains) {
                    } else {
                        countyLists.add(county.toString());
                        s.put("countyCode", countyCode);
                        s.put("county", county);
                        codelists.add(s);
                    }
                }
                if (pId != null && !"".equals(pId)) {
                    boolean contains = dseid.contains(id);
                    if (contains) {
                    } else {
                        dseid.add(String.valueOf(id));
                    }
                }
            }
        }
        Map<String, Object> newMap = new HashMap<>();
        newMap.put("beginTime", map.get("beginTime"));
        newMap.put("endTime", map.get("endTime"));
        newMap.put("drinksources", dseid);
        newMap.put("isWhether", map.get("isWhether"));
        Map<String, Object> datalist = new HashMap<>();
        List<Map<String, Object>> mapList = this.notisoverDrinkSource(newMap);
        DecimalFormat df = new DecimalFormat("0.00");
        List<String> codrmap = new ArrayList<>();
        List<String> codrmapName = new ArrayList<>();
        List<String> seid = new ArrayList<>();
        List<Map<String, Object>> codelist = new ArrayList<>();
        if (mapList != null && mapList.size() > 0) {
            for (Map<String, Object> dat : mapList) {
                Object countyCode = dat.get("countyCode");
                //Object county = dat.get("county");
                Object drinksourceId = dat.get("drinksourceId");
                Object county = dat.get("county");
                boolean contains = codrmap.contains(countyCode);
                boolean countys = codrmapName.contains(county);
                if (countys) {
                } else {
                    codrmapName.add(String.valueOf(county));

                }
                if (contains) {
                } else {
                    codrmap.add(String.valueOf(countyCode));
                    Map<String, Object> s = new HashMap<>();
                    s.put("countyCode", countyCode);
                    s.put("county", county);
                    codelist.add(s);
                }
                boolean drinksourceIds = seid.contains(drinksourceId);
                if (drinksourceIds) {
                } else {
                    seid.add(String.valueOf(drinksourceId));

                }
            }
        }
        datalist.put("countyList", countyLists);
        List<String> levelList = new ArrayList<>();

        levelList.add("1");
        levelList.add("2");
        levelList.add("3");
        levelList.add("4");
        levelList.add("5");
        levelList.add("6");
        levelList.add("0");
        datalist.put("level", levelList);
        List<String> levelNameList = new ArrayList<>();

        levelNameList.add("Ⅰ类");
        levelNameList.add("Ⅱ类");
        levelNameList.add("Ⅲ类");
        levelNameList.add("Ⅳ类");
        levelNameList.add("Ⅴ类");
        levelNameList.add("劣Ⅴ类");
        levelNameList.add("无类别");
        datalist.put("levelName", levelNameList);
        List<Map<String, Object>> list = new ArrayList<>();
        if (codelists != null && codelists.size() > 0) {
            for (Map<String, Object> dat : codelists) {
                Map<String, Object> datas = new HashMap<>();
                List<Map<String, Object>> lists = new ArrayList<>();
                Object countyCode = dat.get("countyCode");
                Object county = dat.get("county");
                datas.put("countyCode", countyCode);
                datas.put("county", county);
                //分组数据
                List<Map<String, Object>> sunmapsLevel = mapList.stream()
                        .filter(item -> item.get("countyCode") != null &&
                                item.get("countyCode").equals(countyCode)
                        )
                        .collect(Collectors.toList());
                // Map<String,Object> datasq=new HashMap<>();

                List<Map<String, Object>> drinkLevel = DrinkSourcesizelsit.stream()
                        .filter(item -> item.get("pId") != null && item.get("CountyCode") != null &&
                                item.get("CountyCode").equals(countyCode)
                        )
                        .collect(Collectors.toList());
                size = drinkLevel.size();

                Integer one = 0;
                Integer two = 0;
                Integer three = 0;
                Integer four = 0;
                Integer five = 0;
                Integer six = 0;
                Integer allsize = 0;

                if (sunmapsLevel != null && sunmapsLevel.size() > 0) {
                    for (Map<String, Object> dats : sunmapsLevel) {
                        Object qualityLevel = dats.get("qualityLevel");
                        Object qualityLevelName = dats.get("qualityLevelName");
                        allsize = allsize + 1;
                        if (qualityLevel != null && !"".equals(qualityLevel)) {
                            Integer integer = Integer.valueOf(String.valueOf(qualityLevel));
                            if (integer == 1) {
                                one = one + 1;
                            }
                            if (integer == 2) {
                                two = two + 1;
                            }
                            if (integer == 3) {
                                three = three + 1;
                            }
                            if (integer == 4) {
                                four = four + 1;
                            }
                            if (integer == 5) {
                                five = five + 1;
                            }
                            if (integer == 6) {
                                six = six + 1;
                            }
                        }

                    }
                }
                Map<String, Object> datas1 = new HashMap<>();
                //占比率 = (部分数量 / 整体数量)× 100%
                if (one > 0) {
                    double v = (Double.valueOf(one) / Double.valueOf(size)) * 100;
                    datas1.put("proportion", df.format(v));
                } else {
                    datas1.put("proportion", "0.00");
                }
                datas1.put("size", one);
                datas1.put("levelName", "Ⅰ类");
                datas1.put("level", "1");
                lists.add(datas1);
                Map<String, Object> datas2 = new HashMap<>();
                //占比率 = (部分数量 / 整体数量)× 100%
                if (two > 0) {
                    double v = (Double.valueOf(two) / Double.valueOf(size)) * 100;
                    datas2.put("proportion", df.format(v));
                } else {
                    datas2.put("proportion", "0.00");
                }
                datas2.put("size", two);
                datas2.put("levelName", "Ⅱ类");
                datas2.put("level", "2");
                lists.add(datas2);
                Map<String, Object> datas3 = new HashMap<>();
                //占比率 = (部分数量 / 整体数量)× 100%
                if (three > 0) {
                    double v = (Double.valueOf(three) / Double.valueOf(size)) * 100;
                    datas3.put("proportion", df.format(v));
                } else {
                    datas3.put("proportion", "0.00");
                }
                datas3.put("size", three);
                datas3.put("levelName", "Ⅲ类");
                datas3.put("level", "3");
                lists.add(datas3);
                Map<String, Object> datas4 = new HashMap<>();
                //占比率 = (部分数量 / 整体数量)× 100%
                if (four > 0) {
                    double v = (Double.valueOf(four) / Double.valueOf(size)) * 100;
                    datas4.put("proportion", df.format(v));
                } else {
                    datas4.put("proportion", "0.00");
                }
                datas4.put("size", four);
                datas4.put("levelName", "Ⅳ类");
                datas4.put("level", "4");
                lists.add(datas4);
                Map<String, Object> datas5 = new HashMap<>();
                //占比率 = (部分数量 / 整体数量)× 100%
                if (five > 0) {
                    double v = (Double.valueOf(five) / Double.valueOf(size)) * 100;
                    datas5.put("proportion", df.format(v));
                } else {
                    datas5.put("proportion", "0.00");
                }
                datas5.put("size", five);
                datas5.put("levelName", "Ⅴ类");
                datas5.put("level", "5");
                lists.add(datas5);
                Map<String, Object> datas6 = new HashMap<>();
                //占比率 = (部分数量 / 整体数量)× 100%
                if (six > 0) {
                    double v = (Double.valueOf(six) / Double.valueOf(size)) * 100;
                    datas6.put("proportion", df.format(v));
                } else {
                    datas6.put("proportion", "0.00");
                }
                datas6.put("size", six);
                datas6.put("levelName", "劣Ⅴ类");
                datas6.put("level", "6");
                lists.add(datas6);
                Map<String, Object> datas7 = new HashMap<>();
                Integer i = Integer.valueOf(size) - allsize;
                //占比率 = (部分数量 / 整体数量)× 100%
                if (i > 0) {
                    double v = (Double.valueOf(i) / Double.valueOf(size)) * 100;
                    datas7.put("proportion", df.format(v));
                } else {
                    datas7.put("proportion", "0.00");
                }
                datas7.put("size", i);
                datas7.put("levelName", "无类别");
                datas7.put("level", "0");
                lists.add(datas7);

                datas.put("list", lists);

                list.add(datas);
                datalist.put("dataList", list);
            }
        }
        return datalist;
    }

    @Override
    public Map<String, Object> getDrinkSourceTrend(String segmentId, String dataType, String itemCode, String beginTime, String endTime) {
        Map<String, Object> retMap = new HashMap<>();
        List<String> segmentIds = Arrays.asList(segmentId.split(","));
        List<String> itemCodes = new ArrayList<>();
        if (StringUtils.isNotEmpty(itemCode)) {
            itemCodes = Arrays.asList(itemCode.split(","));
        }
        Map<String, Object> retMapVo = new HashMap<>();
        retMapVo.put("segmentIds", segmentIds);
        retMapVo.put("itemCodes", itemCodes);
        //获取断面信息
        List<Map<String, Object>> wqSegmentList = manualStatisticsMapper.getWqBasSegmentList(retMapVo);

        Map<String, Object> bussinessMap = new HashMap<>();
        bussinessMap.put("itemCodes", itemCodes);
        List<Map<String, Object>> bussinessItemList = manualStatisticsMapper.getQueryItemDatas(bussinessMap);

        //日期集合
        List<String> dateTimeList = new ArrayList<>();
        List<Map<String, Object>> autoItemCodeList = new ArrayList<>();
        if ("1".equals(dataType)) {//小时
            dateTimeList = DateUtils.getHourBetweenDatetype(beginTime + " 00:00", endTime + " 23:59", "yyyy-MM-dd HH:mm");
            retMapVo.put("beginTime", beginTime + " 00:00:00");
            retMapVo.put("endTime", endTime + " 23:59:59");
            autoItemCodeList = manualStatisticsMapper.autoSegmentItemHourData(retMapVo);
        } else if ("2".equals(dataType)) {//日
            dateTimeList = DateUtils.getdayBetweenDate(beginTime, endTime);
            retMapVo.put("beginTime", beginTime + " 00:00:00");
            retMapVo.put("endTime", endTime + " 23:59:59");
            autoItemCodeList = manualStatisticsMapper.autoSegmentItemDayData(retMapVo);

        } else if ("3".equals(dataType)) {//月
            retMapVo.put("beginTime", beginTime + "-01 00:00:00");
            retMapVo.put("endTime", DateUtils.getLastDayOfMonth(DateUtils.dateTime("yyyy-MM", endTime)) + " 23:59:59");
            dateTimeList = DateUtils.getMonthBetweenDate(beginTime, endTime);
            autoItemCodeList = manualStatisticsMapper.autoSegmentItemMonthData(retMapVo);
        }

        Map<String, List<Map<String, Object>>> autoItemCodeColl = autoItemCodeList.stream().collect(Collectors.groupingBy(s -> String.valueOf(s.get("itemCode"))));
        //按照升序排序
        List<Map<String, Object>> retList = new ArrayList<>();
        for (Map<String, Object> segmentMap : wqSegmentList) {
            String segmentCode = String.valueOf(segmentMap.get("id"));
            String segmentName = String.valueOf(segmentMap.get("segmentName"));
            for (Map<String, Object> bussinessItems : bussinessItemList) {
                Map<String, Object> map = new HashMap<>();
                String itembm = String.valueOf(bussinessItems.get("itemCode"));
                String itemName = String.valueOf(bussinessItems.get("itemName"));
                String unit = String.valueOf(bussinessItems.get("unit"));
                String hourShowPointBits = String.valueOf(bussinessItems.get("HourShowPointBits"));
                String keepPointBits = String.valueOf(bussinessItems.get("KeepPointBits"));
                List<Map<String, Object>> autoItemList = autoItemCodeColl.get(itembm);

                if (StringUtils.isNotEmpty(autoItemList) && autoItemList.size() > 0) {
                    int keepPointBit = 3;
                    if ("0".equals(dataType)) {
                        keepPointBit = Integer.parseInt(hourShowPointBits);
                    } else {
                        keepPointBit = Integer.parseInt(keepPointBits);
                    }
                   List<Map<String,Object>> segmentAutoDatas=autoItemList.stream().filter(s->String.valueOf(s.get("segmentId")).equals(segmentCode)).collect(Collectors.toList());
                    //循环处理
                    for (Map<String, Object> autoItemData : segmentAutoDatas) {
                        autoItemData.put("effectiveValue", new BigDecimal(String.valueOf(autoItemData.get("effectiveValue"))).setScale(keepPointBit, BigDecimal.ROUND_HALF_UP));
                    }
                }

                map.put("autoItemList", autoItemList);
                map.put("id", itemCode);
                map.put("itemName", itemName);
                map.put("segmentName", segmentName);
                map.put("unit", unit);
                retList.add(map);
            }
        }
        retMap.put("dateTime", dateTimeList);
        retMap.put("itemList", retList);
        return retMap;
    }

    public List<Map<String, Object>> notisoverDrinkSource(Map<String, Object> map) {

        Object dataType = map.get("dataType");
        Object beginTime = map.get("beginTime");//开始时间
        Object endTime = map.get("endTime");//结束时间
        Object isWhether = map.get("isWhether");//结束时间
        List<String> drinksources = (List<String>) map.get("drinksources");//水源地id
        //获取同比时间
        String tbksData = null;
        String tbjsData = null;
        Map<String, Object> stringObjectMap = DateUtils.OnTheSameMonthRatio(String.valueOf(beginTime), String.valueOf(endTime), "yyyy-MM");
        if (stringObjectMap != null && stringObjectMap.size() > 0) {
            tbksData = (String) stringObjectMap.get("tbksData");
            tbjsData = (String) stringObjectMap.get("tbjsData");
        }
        //查询对应标准值
        List<Map<String, Object>> sectionStandardCalculationlist = new ArrayList<>();
        Map<String, Object> getbasicsmonitordatamap = new HashMap<>();
        List<Map> sectionStandardCalculationlists = publicToolsMapper.sectionStandardCalculation(getbasicsmonitordatamap);
        if (sectionStandardCalculationlists != null && sectionStandardCalculationlists.size() > 0) {
            for (Map daya : sectionStandardCalculationlists) {
                sectionStandardCalculationlist.add(daya);
            }
        }
        //查询对应因子修约位数
        Map<String, Object> itemap = new HashMap<>();
        itemap.put("bussinessCategoryCodeCBF", "1");
        List<Map<String, Object>> wqCodBussinessitemsbussinessCategoryCodelist = publicToolsMapper.wqCodBussinessitemsbussinessCategoryCode(itemap);

        //查询监测数据
        List<Map<String, Object>> isoverDrinkSourcelist = manualStatisticsMapper.isoverDrinkSource(map);
        List<Map<String, Object>> tbisoverDrinkSourcelist = new ArrayList<>();
        if (isWhether != null && isWhether.equals("1")) {
            map.put("beginTime", tbksData);
            map.put("endTime", tbjsData);
            tbisoverDrinkSourcelist = manualStatisticsMapper.isoverDrinkSource(map);
        }
        DecimalFormat df = new DecimalFormat("#0.00");
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //循环水源地进行数据分离处理
        List<Map<String, Object>> listdata = new ArrayList<>();
        if (drinksources != null && drinksources.size() > 0) {
            for (String dataId : drinksources) {
                Map<String, Object> datamap = new HashMap<>();
                datamap.put("type", "当期");
                Map<String, Object> tbdatamap = new HashMap<>();
                Double isoverqsl = 0.0;//达标取水量
                Double allisoverqsl = 0.0;//全部取水量
                Integer maxqualityLevel = 0;//断面级别
                Double tbisoverqsl = 0.0;//达标取水量
                Double tballisoverqsl = 0.0;//全部取水量
                Integer tbmaxqualityLevel = 0;//断面级别
                //分组查询数据
                List<Map<String, Object>> sunmapsLevel = isoverDrinkSourcelist.stream()
                        .filter(item -> item.get("segmentID").equals(dataId)
                        )
                        .collect(Collectors.toList());
                List<Map<String, Object>> tbsunmapsLevel = new ArrayList<>();
                if (isWhether != null && isWhether.equals("1")) {
                    tbsunmapsLevel = tbisoverDrinkSourcelist.stream()
                            .filter(item -> item.get("segmentID").equals(dataId)
                            )
                            .collect(Collectors.toList());
                }
                if (sunmapsLevel != null && sunmapsLevel.size() > 0) {
                    for (Map<String, Object> data : sunmapsLevel) {
                        Object monSampleDate = data.get("monSampleDate");//时间
                        Object segmentID = data.get("segmentID");//水源地id
                        Object segmentName = data.get("segmentName");//水源地名称
                        Object drinksourceType = data.get("drinksourceType");//水源地类型（河流-1/湖库-2/地下水-3）
                        Object segmentCategory = data.get("segmentCategory");//水源地类型（0地表 1地下）
                        Object drinkSourceLevel = data.get("drinkSourceLevel");//水源地级别（0城市、1县级以上、2千吨万人、3千人以上、4乡镇、5其他）
                        Object itemCode = data.get("itemCode");//因子编码
                        Object itemName = data.get("itemName");//因子名称
                        Object effectiveValue = data.get("effectiveValue");//均值
                        Object county = data.get("county");//区划编码
                        Object targetLevelName = data.get("targetLevelName");//目标级别名称
                        Object targetLevel = data.get("targetLevel");//目标级别编码
                        Object drinkSourceLevelName = data.get("drinkSourceLevelName");//水源地级别名称
                        Object drinksourceTypeName = data.get("drinksourceTypeNmae");//水源地类型 名称
                        Object countyCode = data.get("countyCode");//区划名称
                        Object populationCovered = data.get("populationCovered");//设计服务人口
                        Object province = data.get("province");//省份
                        Object qsksize = data.get("size");//省份
                        Object provinceCode = data.get("provinceCode");//省份
                        //先把基本信息存入
                        datamap.put("province", province);
                        datamap.put("qsksize", qsksize);
                        datamap.put("provinceCode", provinceCode);
                        //datamap.put("monSampleDate",monSampleDate);
                        datamap.put("drinksourceId", segmentID);
                        datamap.put("drinksourceName", segmentName);
                        datamap.put("drinksourceType", drinksourceType);
                        datamap.put("drinkSourceLevel", drinkSourceLevel);
                        datamap.put("segmentCategory", segmentCategory);
                        datamap.put("drinkSourceLevelName", drinkSourceLevelName);
                        datamap.put("drinksourceTypeName", drinksourceTypeName);
                        datamap.put("targetLevel", targetLevel);
                        datamap.put("targetLevelName", targetLevelName);
                        datamap.put("countyCode", countyCode);
                        datamap.put("county", county);
                        datamap.put("populationCovered", populationCovered);
                        datamap.put(itemCode + "_code", itemCode);
                        String BussinessCategoryCode = null;
                        String isevr = "0";
                        if (drinksourceType != null && !"".equals(drinksourceType)) {
                            if ("1".equals(String.valueOf(drinksourceType))) {
                                BussinessCategoryCode = "CBF1";
                            } else if ("2".equals(String.valueOf(drinksourceType))) {
                                BussinessCategoryCode = "CBF1";
                            } else if ("3".equals(String.valueOf(drinksourceType))) {
                                BussinessCategoryCode = "CBF8";
                            }
                        }
                        if (wqCodBussinessitemsbussinessCategoryCodelist != null && wqCodBussinessitemsbussinessCategoryCodelist.size() > 0) {
                            String finalBussinessCategoryCode = BussinessCategoryCode;
                            List<Map<String, Object>> sunmapsLeveless = wqCodBussinessitemsbussinessCategoryCodelist.stream()
                                    .filter(item -> item.get("BussinessCategoryCode").equals(finalBussinessCategoryCode)
                                            && item.get("ItemCode").equals(itemCode)
                                    )
                                    .collect(Collectors.toList());
                            if (sunmapsLeveless != null && sunmapsLeveless.size() > 0) {
                                Map<String, Object> map1 = sunmapsLeveless.get(0);
                                Object isEvalute = map1.get("IsEvalute");
                                if (isEvalute != null && !"".equals(isEvalute)) {
                                    isevr = String.valueOf(isEvalute);
                                }
                            }
                        }
                        //处理因子数据
                        if (effectiveValue != null && !"".equals(effectiveValue)) {
                            //判断是否科学计算法，如果是就进行转换
                            boolean scientificNotation = StringUtils.isScientificNotation(String.valueOf(effectiveValue));
                            if (scientificNotation) {
                                BigDecimal bigDecimal = new BigDecimal(String.valueOf(effectiveValue));
                                String effectiveValuesdatas = bigDecimal.toPlainString();
                                effectiveValue = effectiveValuesdatas;
                            } else {
                                effectiveValue = String.valueOf(effectiveValue);
                            }
                        }
                        //监测因子进行修约
                        String xyvalueData = "";
                        String keepPointBitss = "3";
                        if (effectiveValue != null && !"".equals(effectiveValue) && !"-1".equals(effectiveValue)) {
                            if (wqCodBussinessitemsbussinessCategoryCodelist != null && wqCodBussinessitemsbussinessCategoryCodelist.size() > 0) {
                                List<Map<String, Object>> ItemCodeLevel = wqCodBussinessitemsbussinessCategoryCodelist.stream()
                                        .filter(item -> item.get("ItemCode").equals(itemCode)
                                        )
                                        .collect(Collectors.toList());
                                if (ItemCodeLevel != null && ItemCodeLevel.size() > 0) {
                                    Object keepPointBits = ItemCodeLevel.get(0).get("KeepPointBits");
                                    if (keepPointBits != null && !"".equals(keepPointBits)) {
                                        keepPointBitss = String.valueOf(keepPointBits);
                                    }
                                }
                            }
                            BigDecimal number = new BigDecimal(String.valueOf(effectiveValue));
                            xyvalueData = String.valueOf(number);
                        } else {
                            xyvalueData = "-1";
                        }
                        if (itemName != null && !"".equals(itemName)) {
                            //下面进行数据计算和处理
                            if (effectiveValue != null && !"".equals(effectiveValue) && !"-1".equals(effectiveValue)) {
                                if (sectionStandardCalculationlist != null && sectionStandardCalculationlist.size() > 0) {
                                    //数据分组  SegmentCategory  ItemCode Level
                                    //分组判断，stream流 //断面类型
                                    List<Map<String, Object>> sunmapsitemCodelist = new ArrayList<>();
                                    Map<String, List<Map<String, Object>>> sunmapsSegmentCategory =
                                            sectionStandardCalculationlist.stream().collect(
                                                    Collectors.groupingBy(item -> item.get("WaterType").toString())
                                            );
                                    //SegmentCategorys 断面类型分组
                                    List<Map<String, Object>> sunmapsSegmentCategorylist = sunmapsSegmentCategory.get(String.valueOf(drinksourceType));
                                    //因子名称分组
                                    if (sunmapsSegmentCategorylist != null && sunmapsSegmentCategorylist.size() > 0) {
                                        Map<String, List<Map<String, Object>>> sunmapsitemCode =
                                                sunmapsSegmentCategorylist.stream().collect(
                                                        Collectors.groupingBy(item -> item.get("ItemCode").toString())
                                                );
                                        sunmapsitemCodelist = sunmapsitemCode.get(itemCode);
                                    }
                                    //断面标准计算进行转换list
                                    List<Standard> Standardlist = new ArrayList<>();
                                    if (sunmapsitemCodelist != null && sunmapsitemCodelist.size() > 0) {
                                        for (Map<String, Object> sunmapsitemCodelistdata : sunmapsitemCodelist) {
                                            Object standardValue = sunmapsitemCodelistdata.get("StandardValue");//标准值
                                            Object compareMethod = sunmapsitemCodelistdata.get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
                                            Object Level = sunmapsitemCodelistdata.get("Level");//级别
                                            if (Level != null && !"".equals(Level)) {
                                                if (String.valueOf(Level).equals("3")) {
                                                    if (compareMethod != null && !"".equals(compareMethod)) {
                                                        if (compareMethod.equals("0")) {
                                                            if (Double.valueOf(String.valueOf(xyvalueData)) > Double.valueOf(String.valueOf(standardValue))) {
                                                                //map.put("Isoverstandard2", "1");
                                                                //超标倍数=（超标数据-标准）/标准 OverStandardTimes1
                                                                Double v = (Double.valueOf(String.valueOf(xyvalueData)) - Double.valueOf(String.valueOf(standardValue))) / Double.valueOf(String.valueOf(standardValue));
                                                                String format = df.format(v);
                                                                //map.put("Overstandardtimes2", format);
                                                                datamap.put(itemCode + "_OverTimes", "1");
                                                                datamap.put(itemCode + "_isover", format);
                                                                String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), Integer.valueOf(keepPointBitss));
                                                                datamap.put(itemCode + "_Val", s);
                                                            } else {
                                                                datamap.put(itemCode + "_OverTimes", "0");
                                                                datamap.put(itemCode + "_isover", "");
                                                                String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), Integer.valueOf(keepPointBitss));
                                                                datamap.put(itemCode + "_Val", s);
                                                            }
                                                        }
                                                        if (compareMethod.equals("1")) {
                                                            if (Double.valueOf(String.valueOf(xyvalueData)) <= Double.valueOf(String.valueOf(standardValue))) {
                                                                //map.put("Isoverstandard2", "1");
                                                                datamap.put(itemCode + "_OverTimes", "1");
                                                                datamap.put(itemCode + "_isover", "");
                                                                String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), Integer.valueOf(keepPointBitss));
                                                                datamap.put(itemCode + "_Val", s);
                                                            } else {
                                                                datamap.put(itemCode + "_OverTimes", "0");
                                                                datamap.put(itemCode + "_isover", "");
                                                                String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), Integer.valueOf(keepPointBitss));
                                                                datamap.put(itemCode + "_Val", s);
                                                            }
                                                        }
                                                        if (compareMethod.equals("2")) {
                                                            if (Double.valueOf(String.valueOf(xyvalueData)) > Double.valueOf(String.valueOf(standardValue))) {
                                                                // map.put("Isoverstandard2", "1");
                                                                datamap.put(itemCode + "_OverTimes", "1");
                                                                datamap.put(itemCode + "_isover", "");
                                                                String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), Integer.valueOf(keepPointBitss));
                                                                datamap.put(itemCode + "_Val", s);
                                                            } else {
                                                                datamap.put(itemCode + "_OverTimes", "0");
                                                                datamap.put(itemCode + "_isover", "");
                                                                String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), Integer.valueOf(keepPointBitss));
                                                                datamap.put(itemCode + "_Val", s);
                                                            }

                                                        }
                                                    }
                                                }


                                            }


                                        }
                                    } else {
                                        datamap.put(itemCode + "_OverTimes", "0");
                                        datamap.put(itemCode + "_isover", "");
                                        String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                        datamap.put(itemCode + "_Val", s);
                                    }
                                    if (sunmapsitemCodelist != null && sunmapsitemCodelist.size() > 0) {
                                        for (Map s : sunmapsitemCodelist) {
                                            Standard Standard = new Standard();//计算标准实体类
                                            Object waterType = s.get("WaterType");//水体类型
                                            Object StartDate = s.get("StartDate");//开始时间
                                            Object EndDate = s.get("EndDate");//结束时间
                                            Object ItemCodes = s.get("ItemCode");//监测项编码
                                            Object Level = s.get("Level");//水质级别
                                            Object CompareMethod = s.get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
                                            Object StandardValue = s.get("StandardValue");//标准值
                                            Object Type = s.get("Type");//监测项目标准分类（常规、特殊）
                                            Object StandardCategory = s.get("StandardCategory");//标准类别（河流/湖库/地下水）
                                            //下面判读数据不为空进行数据处理到实体类里面
                                            if (waterType != null && !"".equals(waterType)) {
                                                Standard.setWaterType(String.valueOf(waterType));
                                            } else {
                                                Standard.setWaterType("");
                                            }
                                            if (StartDate != null && !"".equals(StartDate)) {
                                                String StartDateString = String.valueOf(StartDate);
                                                Date StartDateStringparse = null;
                                                try {
                                                    StartDateStringparse = dateFormat.parse(StartDateString);
                                                } catch (ParseException e) {
                                                    e.printStackTrace();
                                                }
                                                Standard.setStartDate(StartDateStringparse);
                                            }
                                            if (EndDate != null && !"".equals(EndDate)) {
                                                String EndDateString = String.valueOf(EndDate);
                                                Date EndDateStringparse = null;
                                                try {
                                                    EndDateStringparse = dateFormat.parse(EndDateString);
                                                } catch (ParseException e) {
                                                    e.printStackTrace();
                                                }
                                                Standard.setEndDate(EndDateStringparse);
                                            }
                                            if (ItemCodes != null && !"".equals(ItemCodes)) {
                                                Standard.setItemCode(String.valueOf(ItemCodes));
                                            } else {
                                                Standard.setItemCode("");
                                            }
                                            if (Level != null && !"".equals(Level)) {
                                                Standard.setLevel(String.valueOf(Level));
                                            } else {
                                                Standard.setLevel("");
                                            }
                                            if (StandardValue != null && !"".equals(StandardValue)) {
                                                Standard.setStandardValue(String.valueOf(StandardValue));
                                            } else {
                                                Standard.setStandardValue("");
                                            }
                                            if (Type != null && !"".equals(Type)) {
                                                Standard.setType(String.valueOf(Type));
                                            } else {
                                                Standard.setType("");
                                            }
                                            if (StandardCategory != null && !"".equals(StandardCategory)) {
                                                Standard.setStandardCategory(String.valueOf(StandardCategory));
                                            } else {
                                                Standard.setStandardCategory("");
                                            }
                                            if (CompareMethod != null && !"".equals(CompareMethod)) {
                                                Standard.setCompareMethod(String.valueOf(CompareMethod));
                                            } else {
                                                Standard.setCompareMethod("");
                                            }
                                            Standardlist.add(Standard);
                                        }
                                    }
                                    if (itemCode != null && "15DE941F-A221-4D9C-8387-48B0E99F6E25".equals(itemCode)) {
                                        if (Double.valueOf(String.valueOf(xyvalueData)) >= 6 && Double.valueOf(String.valueOf(xyvalueData)) <= 9) {
                                            datamap.put(itemCode + "_OverTimes", "0");
                                            datamap.put(itemCode + "_isover", "");
                                            String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), Integer.valueOf(keepPointBitss));
                                            datamap.put(itemCode + "_Val", s);
                                        } else {
                                            datamap.put(itemCode + "_OverTimes", "1");
                                            datamap.put(itemCode + "_isover", "");
                                            String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), Integer.valueOf(keepPointBitss));
                                            datamap.put(itemCode + "_Val", s);

                                        }

                                    }
                                    //判断查询取水量数据是否超标
                                    if (itemCode != null && "A2275767-FE7C-466D-83F1-D9D04A18C78D".equals(itemCode)) {
                                        Object o = datamap.get(itemCode + "_OverTimes");
                                        if (o != null && !o.equals("1")) {
                                            isoverqsl = isoverqsl + Double.valueOf(String.valueOf(effectiveValue));
                                        }
                                        allisoverqsl = allisoverqsl + Double.valueOf(String.valueOf(effectiveValue));

                                    }
                                    //计算水质级别
                                    if ("1".equals(isevr) && itemCode != null && !"6F2E428C-2705-4DC1-A1D8-235CB9330593".equals(itemCode)) {
                                        if (xyvalueData != null && !"".equals(xyvalueData) && !"-1".equals(xyvalueData)) {
                                            Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(xyvalueData)), Standardlist, String.valueOf(itemCode), String.valueOf(xyvalueData), Integer.valueOf(String.valueOf(segmentCategory)));
                                            //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                            if (integer != null) {
                                                integer = integer;//断面计算出的级别
                                            } else {
                                                //断面计算出的级别
                                                integer = 0;
                                            }
                                            //转换水质级别名称
                                            //   String LevelName = WaterLevelCompute.GetLevelName(integer,"");
                                            if (integer > maxqualityLevel) {
                                                maxqualityLevel = integer;
                                            }
                                        }
                                    }


                                }
                            }
                        }

                    }
                    //计算水量达标率  达标率 =(达标学生人数/学生总人数)×100%

                    //datamap.put("waterVolume","");//水量达标率

                    datamap.put("qualityLevel", maxqualityLevel);
                    Double sldb = 0.0;
                    //转换水质级别名称
                    String LevelName = WaterLevelCompute.GetLevelName(maxqualityLevel, null);
                    datamap.put("qualityLevelName", LevelName);
                    Double syddb = 0.0;
                    if (allisoverqsl != null && !"".equals(allisoverqsl) && Double.valueOf(allisoverqsl) > 0) {
                        if (isoverqsl != null && !"".equals(isoverqsl) && Double.valueOf(isoverqsl) > 0) {
                            double v = (Double.valueOf(isoverqsl) / Double.valueOf(allisoverqsl)) * 100;
                            sldb = v;
                            datamap.put("waterVolume", df.format(v));
                        }
                    } else {
                        datamap.put("waterVolume", "-");

                    }
                    if (maxqualityLevel <= 3) {

                        double v = allisoverqsl - isoverqsl;
                        String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(allisoverqsl)), 4);
                        if (s != null && Double.valueOf(s) > 0) {
                            datamap.put("waterIntake", s);
                        } else {
                            datamap.put("waterIntake", "-");
                        }
                        syddb = 100.0;
                        datamap.put("isover", "100.00");
                        String sq = segmentFormula.assessmentOfWater(sldb, syddb);
                        datamap.put("evaluationScore", sq);
                        String s1 = segmentFormula.assessmentOfWaterresult(Double.valueOf(sq));
                        datamap.put("evaluationResults", s1);
                        listdata.add(datamap);
                    } else {
                        datamap.put("isover", "0");
                        datamap.put("waterIntake", "-");
                    }
                } else {

                }
                if (isWhether != null && isWhether.equals("1")) {
                    if (tbsunmapsLevel != null && tbsunmapsLevel.size() > 0) {
                        for (Map<String, Object> data : tbsunmapsLevel) {
                            Object monSampleDate = data.get("monSampleDate");//时间
                            Object segmentID = data.get("segmentID");//水源地id
                            Object segmentName = data.get("segmentName");//水源地名称
                            Object drinksourceType = data.get("drinksourceType");//水源地类型（河流-1/湖库-2/地下水-3）
                            Object segmentCategory = data.get("segmentCategory");//水源地类型（0地表 1地下）
                            Object drinkSourceLevel = data.get("drinkSourceLevel");//水源地级别（0城市、1县级以上、2千吨万人、3千人以上、4乡镇、5其他）
                            Object itemCode = data.get("itemCode");//因子编码
                            Object itemName = data.get("itemName");//因子名称
                            Object effectiveValue = data.get("effectiveValue");//均值
                            Object county = data.get("county");//区划编码
                            Object targetLevelName = data.get("targetLevelName");//目标级别名称
                            Object targetLevel = data.get("targetLevel");//目标级别编码
                            Object drinkSourceLevelName = data.get("drinkSourceLevelName");//水源地级别名称
                            Object drinksourceTypeName = data.get("drinksourceTypeNmae");//水源地类型 名称
                            Object countyCode = data.get("countyCode");//区划名称
                            Object populationCovered = data.get("populationCovered");//设计服务人口
                            Object province = data.get("province");//省份
                            Object provinceCode = data.get("provinceCode");//省份
                            //先把基本信息存入
                            tbdatamap.put("province", province);
                            tbdatamap.put("provinceCode", provinceCode);
                            //datamap.put("monSampleDate",monSampleDate);
                            tbdatamap.put("drinksourceId", segmentID);
                            tbdatamap.put("drinksourceName", segmentName);
                            tbdatamap.put("drinksourceType", drinksourceType);
                            tbdatamap.put("drinkSourceLevel", drinkSourceLevel);
                            tbdatamap.put("segmentCategory", segmentCategory);
                            tbdatamap.put("drinkSourceLevelName", drinkSourceLevelName);
                            tbdatamap.put("drinksourceTypeName", drinksourceTypeName);
                            tbdatamap.put("targetLevel", targetLevel);
                            tbdatamap.put("targetLevelName", targetLevelName);
                            tbdatamap.put("countyCode", countyCode);
                            tbdatamap.put("county", county);
                            tbdatamap.put("type", "同比");
                            tbdatamap.put("populationCovered", populationCovered);
                            tbdatamap.put(itemCode + "_code", itemCode);
                            String BussinessCategoryCode = null;
                            String isevr = "0";
                            if (drinksourceType != null && !"".equals(drinksourceType)) {
                                if ("1".equals(String.valueOf(drinksourceType))) {
                                    BussinessCategoryCode = "CBF1";
                                } else if ("2".equals(String.valueOf(drinksourceType))) {
                                    BussinessCategoryCode = "CBF1";
                                } else if ("3".equals(String.valueOf(drinksourceType))) {
                                    BussinessCategoryCode = "CBF8";
                                }
                            }
                            if (wqCodBussinessitemsbussinessCategoryCodelist != null && wqCodBussinessitemsbussinessCategoryCodelist.size() > 0) {
                                String finalBussinessCategoryCode = BussinessCategoryCode;
                                List<Map<String, Object>> sunmapsLeveless = wqCodBussinessitemsbussinessCategoryCodelist.stream()
                                        .filter(item -> item.get("BussinessCategoryCode").equals(finalBussinessCategoryCode)
                                                && item.get("ItemCode").equals(itemCode)
                                        )
                                        .collect(Collectors.toList());
                                if (sunmapsLeveless != null && sunmapsLeveless.size() > 0) {
                                    Map<String, Object> map1 = sunmapsLeveless.get(0);
                                    Object isEvalute = map1.get("IsEvalute");
                                    if (isEvalute != null && !"".equals(isEvalute)) {
                                        isevr = String.valueOf(isEvalute);
                                    }
                                }
                            }
                            //处理因子数据
                            if (effectiveValue != null && !"".equals(effectiveValue)) {
                                //判断是否科学计算法，如果是就进行转换
                                boolean scientificNotation = StringUtils.isScientificNotation(String.valueOf(effectiveValue));
                                if (scientificNotation) {
                                    BigDecimal bigDecimal = new BigDecimal(String.valueOf(effectiveValue));
                                    String effectiveValuesdatas = bigDecimal.toPlainString();
                                    effectiveValue = effectiveValuesdatas;
                                } else {
                                    effectiveValue = String.valueOf(effectiveValue);
                                }
                            }
                            //监测因子进行修约
                            String xyvalueData = "";
                            if (effectiveValue != null && !"".equals(effectiveValue) && !"-1".equals(effectiveValue)) {
                                String keepPointBitss = "3";

                                if (wqCodBussinessitemsbussinessCategoryCodelist != null && wqCodBussinessitemsbussinessCategoryCodelist.size() > 0) {
                                    List<Map<String, Object>> ItemCodeLevel = wqCodBussinessitemsbussinessCategoryCodelist.stream()
                                            .filter(item -> item.get("ItemCode").equals(itemCode)
                                            )
                                            .collect(Collectors.toList());
                                    if (ItemCodeLevel != null && ItemCodeLevel.size() > 0) {
                                        Object keepPointBits = ItemCodeLevel.get(0).get("KeepPointBits");
                                        if (keepPointBits != null && !"".equals(keepPointBits)) {
                                            keepPointBitss = String.valueOf(keepPointBits);
                                        }
                                    }
                                }
                                BigDecimal number = new BigDecimal(String.valueOf(effectiveValue));
                                xyvalueData = String.valueOf(number);
                            } else {
                                xyvalueData = "-1";
                            }
                            if (itemName != null && !"".equals(itemName)) {
                                //下面进行数据计算和处理
                                if (effectiveValue != null && !"".equals(effectiveValue) && !"-1".equals(effectiveValue)) {
                                    if (sectionStandardCalculationlist != null && sectionStandardCalculationlist.size() > 0) {
                                        //数据分组  SegmentCategory  ItemCode Level
                                        //分组判断，stream流 //断面类型
                                        List<Map<String, Object>> sunmapsitemCodelist = new ArrayList<>();
                                        Map<String, List<Map<String, Object>>> sunmapsSegmentCategory =
                                                sectionStandardCalculationlist.stream().collect(
                                                        Collectors.groupingBy(item -> item.get("WaterType").toString())
                                                );
                                        //SegmentCategorys 断面类型分组
                                        List<Map<String, Object>> sunmapsSegmentCategorylist = sunmapsSegmentCategory.get(String.valueOf(drinksourceType));
                                        //因子名称分组
                                        if (sunmapsSegmentCategorylist != null && sunmapsSegmentCategorylist.size() > 0) {
                                            Map<String, List<Map<String, Object>>> sunmapsitemCode =
                                                    sunmapsSegmentCategorylist.stream().collect(
                                                            Collectors.groupingBy(item -> item.get("ItemCode").toString())
                                                    );
                                            sunmapsitemCodelist = sunmapsitemCode.get(itemCode);
                                        }
                                        //断面标准计算进行转换list
                                        List<Standard> Standardlist = new ArrayList<>();
                                        if (sunmapsitemCodelist != null && sunmapsitemCodelist.size() > 0) {
                                            for (Map<String, Object> sunmapsitemCodelistdata : sunmapsitemCodelist) {
                                                Object standardValue = sunmapsitemCodelistdata.get("StandardValue");//标准值
                                                Object compareMethod = sunmapsitemCodelistdata.get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
                                                Object Level = sunmapsitemCodelistdata.get("Level");//级别
                                                if (Level != null && !"".equals(Level)) {
                                                    if (String.valueOf(Level).equals("3")) {
                                                        if (compareMethod != null && !"".equals(compareMethod)) {
                                                            if (compareMethod.equals("0")) {
                                                                if (Double.valueOf(String.valueOf(xyvalueData)) > Double.valueOf(String.valueOf(standardValue))) {
                                                                    //map.put("Isoverstandard2", "1");
                                                                    //超标倍数=（超标数据-标准）/标准 OverStandardTimes1
                                                                    Double v = (Double.valueOf(String.valueOf(xyvalueData)) - Double.valueOf(String.valueOf(standardValue))) / Double.valueOf(String.valueOf(standardValue));
                                                                    String format = df.format(v);
                                                                    //map.put("Overstandardtimes2", format);
                                                                    tbdatamap.put(itemCode + "_OverTimes", "1");
                                                                    tbdatamap.put(itemCode + "_isover", format);
                                                                    String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                                                    tbdatamap.put(itemCode + "_Val", s);
                                                                } else {
                                                                    tbdatamap.put(itemCode + "_OverTimes", "0");
                                                                    tbdatamap.put(itemCode + "_isover", "");
                                                                    String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                                                    tbdatamap.put(itemCode + "_Val", s);
                                                                }
                                                            }
                                                            if (compareMethod.equals("1")) {
                                                                if (Double.valueOf(String.valueOf(xyvalueData)) <= Double.valueOf(String.valueOf(standardValue))) {
                                                                    //map.put("Isoverstandard2", "1");
                                                                    tbdatamap.put(itemCode + "_OverTimes", "1");
                                                                    tbdatamap.put(itemCode + "_isover", "");
                                                                    String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                                                    tbdatamap.put(itemCode + "_Val", s);
                                                                } else {
                                                                    tbdatamap.put(itemCode + "_OverTimes", "0");
                                                                    tbdatamap.put(itemCode + "_isover", "");
                                                                    String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                                                    tbdatamap.put(itemCode + "_Val", s);
                                                                }
                                                            }
                                                            if (compareMethod.equals("2")) {
                                                                if (Double.valueOf(String.valueOf(xyvalueData)) > Double.valueOf(String.valueOf(standardValue))) {
                                                                    // map.put("Isoverstandard2", "1");
                                                                    tbdatamap.put(itemCode + "_OverTimes", "1");
                                                                    tbdatamap.put(itemCode + "_isover", "");
                                                                    String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                                                    tbdatamap.put(itemCode + "_Val", s);
                                                                } else {
                                                                    tbdatamap.put(itemCode + "_OverTimes", "0");
                                                                    tbdatamap.put(itemCode + "_isover", "");
                                                                    String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                                                    tbdatamap.put(itemCode + "_Val", s);
                                                                }

                                                            }
                                                        }
                                                    }


                                                }


                                            }
                                        } else {
                                            tbdatamap.put(itemCode + "_OverTimes", "0");
                                            tbdatamap.put(itemCode + "_isover", "");
                                            String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                            tbdatamap.put(itemCode + "_Val", s);
                                        }
                                        if (sunmapsitemCodelist != null && sunmapsitemCodelist.size() > 0) {
                                            for (Map s : sunmapsitemCodelist) {
                                                Standard Standard = new Standard();//计算标准实体类
                                                Object waterType = s.get("WaterType");//水体类型
                                                Object StartDate = s.get("StartDate");//开始时间
                                                Object EndDate = s.get("EndDate");//结束时间
                                                Object ItemCodes = s.get("ItemCode");//监测项编码
                                                Object Level = s.get("Level");//水质级别
                                                Object CompareMethod = s.get("CompareMethod");//比对方法（0<= ，1>=，2>，3有或无，4未检出）
                                                Object StandardValue = s.get("StandardValue");//标准值
                                                Object Type = s.get("Type");//监测项目标准分类（常规、特殊）
                                                Object StandardCategory = s.get("StandardCategory");//标准类别（河流/湖库/地下水）
                                                //下面判读数据不为空进行数据处理到实体类里面
                                                if (waterType != null && !"".equals(waterType)) {
                                                    Standard.setWaterType(String.valueOf(waterType));
                                                } else {
                                                    Standard.setWaterType("");
                                                }
                                                if (StartDate != null && !"".equals(StartDate)) {
                                                    String StartDateString = String.valueOf(StartDate);
                                                    Date StartDateStringparse = null;
                                                    try {
                                                        StartDateStringparse = dateFormat.parse(StartDateString);
                                                    } catch (ParseException e) {
                                                        e.printStackTrace();
                                                    }
                                                    Standard.setStartDate(StartDateStringparse);
                                                }
                                                if (EndDate != null && !"".equals(EndDate)) {
                                                    String EndDateString = String.valueOf(EndDate);
                                                    Date EndDateStringparse = null;
                                                    try {
                                                        EndDateStringparse = dateFormat.parse(EndDateString);
                                                    } catch (ParseException e) {
                                                        e.printStackTrace();
                                                    }
                                                    Standard.setEndDate(EndDateStringparse);
                                                }
                                                if (ItemCodes != null && !"".equals(ItemCodes)) {
                                                    Standard.setItemCode(String.valueOf(ItemCodes));
                                                } else {
                                                    Standard.setItemCode("");
                                                }
                                                if (Level != null && !"".equals(Level)) {
                                                    Standard.setLevel(String.valueOf(Level));
                                                } else {
                                                    Standard.setLevel("");
                                                }
                                                if (StandardValue != null && !"".equals(StandardValue)) {
                                                    Standard.setStandardValue(String.valueOf(StandardValue));
                                                } else {
                                                    Standard.setStandardValue("");
                                                }
                                                if (Type != null && !"".equals(Type)) {
                                                    Standard.setType(String.valueOf(Type));
                                                } else {
                                                    Standard.setType("");
                                                }
                                                if (StandardCategory != null && !"".equals(StandardCategory)) {
                                                    Standard.setStandardCategory(String.valueOf(StandardCategory));
                                                } else {
                                                    Standard.setStandardCategory("");
                                                }
                                                if (CompareMethod != null && !"".equals(CompareMethod)) {
                                                    Standard.setCompareMethod(String.valueOf(CompareMethod));
                                                } else {
                                                    Standard.setCompareMethod("");
                                                }
                                                Standardlist.add(Standard);
                                            }
                                        }
                                        if (itemCode != null && "15DE941F-A221-4D9C-8387-48B0E99F6E25".equals(itemCode)) {
                                            if (Double.valueOf(String.valueOf(xyvalueData)) >= 6 && Double.valueOf(String.valueOf(xyvalueData)) <= 9) {
                                                tbdatamap.put(itemCode + "_OverTimes", "0");
                                                tbdatamap.put(itemCode + "_isover", "");
                                                String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                                tbdatamap.put(itemCode + "_Val", s);
                                            } else {
                                                tbdatamap.put(itemCode + "_OverTimes", "1");
                                                tbdatamap.put(itemCode + "_isover", "");
                                                String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(xyvalueData)), 4);
                                                tbdatamap.put(itemCode + "_Val", s);


                                            }

                                        }
                                        //判断查询取水量数据是否超标
                                        if (itemCode != null && "A2275767-FE7C-466D-83F1-D9D04A18C78D".equals(itemCode)) {
                                            Object o = datamap.get(itemCode + "_OverTimes");
                                            if (o != null && !o.equals("1")) {
                                                tbisoverqsl = tbisoverqsl + Double.valueOf(String.valueOf(effectiveValue));
                                            }
                                            tballisoverqsl = tballisoverqsl + Double.valueOf(String.valueOf(effectiveValue));

                                        }
                                        if ("1".equals(isevr) && itemCode != null && !"6F2E428C-2705-4DC1-A1D8-235CB9330593".equals(itemCode)) {
                                            //计算水质级别
                                            if (xyvalueData != null && !"".equals(xyvalueData) && !"-1".equals(xyvalueData)) {
                                                Integer integer = ItemCodeOverData.GetSingleType(Double.valueOf(String.valueOf(xyvalueData)), Standardlist, String.valueOf(itemCode), String.valueOf(xyvalueData), Integer.valueOf(String.valueOf(segmentCategory)));
                                                //获取到对应级别之后进行转换成水质级别类型名称，返回级别如果不为空 级别*10（因为转换数据需要这种）
                                                if (integer != null) {
                                                    integer = integer;//断面计算出的级别
                                                } else {
                                                    //断面计算出的级别
                                                    integer = 0;
                                                }
                                                //转换水质级别名称
                                                //   String LevelName = WaterLevelCompute.GetLevelName(integer,"");
                                                if (integer > tbmaxqualityLevel) {
                                                    tbmaxqualityLevel = integer;
                                                }
                                            }
                                        }


                                    }
                                }
                            }

                        }
                        tbdatamap.put("qualityLevel", tbmaxqualityLevel);
                        Double sldb = 0.0;
                        // tbdatamap.put("waterVolume","");//水量达标率
                        //转换水质级别名称
                        String LevelName = WaterLevelCompute.GetLevelName(tbmaxqualityLevel, null);
                        tbdatamap.put("qualityLevelName", LevelName);
                        Double syddb = 0.0;
                        //计算水量达标率  达标率 =(达标学生人数/学生总人数)×100%
                        if (tballisoverqsl != null && !"".equals(tballisoverqsl) && Double.valueOf(tballisoverqsl) > 0) {
                            if (tbisoverqsl != null && !"".equals(tbisoverqsl) && Double.valueOf(tbisoverqsl) > 0) {
                                double vs = (Double.valueOf(tbisoverqsl) / Double.valueOf(tballisoverqsl)) * 100;
                                sldb = vs;
                                tbdatamap.put("waterVolume", df.format(vs));
                            }
                        } else {
                            tbdatamap.put("waterVolume", "-");

                        }
                        if (tbmaxqualityLevel <= 3) {
                            double v = tballisoverqsl - tbisoverqsl;
                            String s = BankerSRoundingUtils.sciCal(Double.valueOf(String.valueOf(tballisoverqsl)), 4);
                            //Double sldb=0.0;
                            if (s != null && Double.valueOf(s) > 0) {
                                tbdatamap.put("waterIntake", s);
                            } else {
                                tbdatamap.put("waterIntake", "-");
                            }
                            //tbdatamap.put("waterIntake",s);

                            syddb = 100.0;
                            tbdatamap.put("isover", "100.00");
                            String sq = segmentFormula.assessmentOfWater(sldb, syddb);
                            tbdatamap.put("evaluationScore", sq);
                            String s1 = segmentFormula.assessmentOfWaterresult(Double.valueOf(sq));
                            tbdatamap.put("evaluationResults", s1);
                            listdata.add(tbdatamap);
                        } else {
                            tbdatamap.put("waterIntake", "-");
                            tbdatamap.put("isover", "0");
                        }

                    }

                }

            }
        }


        return listdata;
    }
}
